summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-11-14 22:44:11 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-11-14 22:44:11 (GMT)
commitf456d646b18f6f026225e22bfb88b8e19cc028c9 (patch)
treed13f339b148ea02ef4c535bcbc239f832236b3e2
parent11b9b3e1df6897dbac076aa0d346823370183cf0 (diff)
downloadtk-f456d646b18f6f026225e22bfb88b8e19cc028c9.zip
tk-f456d646b18f6f026225e22bfb88b8e19cc028c9.tar.gz
tk-f456d646b18f6f026225e22bfb88b8e19cc028c9.tar.bz2
ANSIfy
-rw-r--r--generic/tkGrab.c960
-rw-r--r--generic/tkMacWinMenu.c140
-rw-r--r--generic/tkMenu.h495
-rw-r--r--generic/tkMessage.c384
4 files changed, 966 insertions, 1013 deletions
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
index bdf8497..b9b1d3d 100644
--- a/generic/tkGrab.c
+++ b/generic/tkGrab.c
@@ -1,15 +1,15 @@
-/*
+/*
* tkGrab.c --
*
- * This file provides procedures that implement grabs for Tk.
+ * This file provides functions that implement grabs for Tk.
*
* Copyright (c) 1992-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkGrab.c,v 1.10 2004/03/17 18:15:43 das Exp $
+ * RCS: @(#) $Id: tkGrab.c,v 1.11 2005/11/14 22:44:11 dkf Exp $
*/
#include "tkPort.h"
@@ -20,28 +20,26 @@
#endif
/*
- * The grab state machine has four states: ungrabbed, button pressed,
- * grabbed, and button pressed while grabbed. In addition, there are
- * three pieces of grab state information: the current grab window,
- * the current restrict window, and whether the mouse is captured.
- *
- * The current grab window specifies the point in the Tk window
- * heirarchy above which pointer events will not be reported. Any
- * window within the subtree below the grab window will continue to
- * receive events as normal. Events outside of the grab tree will be
- * reported to the grab window.
- *
- * If the current restrict window is set, then all pointer events will
- * be reported only to the restrict window. The restrict window is
- * normally set during an automatic button grab.
- *
- * The mouse capture state specifies whether the window system will
- * report mouse events outside of any Tk toplevels. This is set
- * during a global grab or an automatic button grab.
- *
- * The transitions between different states is given in the following
- * table:
- *
+ * The grab state machine has four states: ungrabbed, button pressed, grabbed,
+ * and button pressed while grabbed. In addition, there are three pieces of
+ * grab state information: the current grab window, the current restrict
+ * window, and whether the mouse is captured.
+ *
+ * The current grab window specifies the point in the Tk window heirarchy
+ * above which pointer events will not be reported. Any window within the
+ * subtree below the grab window will continue to receive events as normal.
+ * Events outside of the grab tree will be reported to the grab window.
+ *
+ * If the current restrict window is set, then all pointer events will be
+ * reported only to the restrict window. The restrict window is normally set
+ * during an automatic button grab.
+ *
+ * The mouse capture state specifies whether the window system will report
+ * mouse events outside of any Tk toplevels. This is set during a global grab
+ * or an automatic button grab.
+ *
+ * The transitions between different states is given in the following table:
+ *
* Event\State U B G GB
* ----------- -- -- -- --
* FirstPress B B GB GB
@@ -62,15 +60,14 @@
* Grabbed 1 0 b/g
* Grab and Button 1 1 1
*
- * Note: 0 means variable is set to NULL, 1 means variable is set to
- * some window, b/g means the variable is set to a window if a button
- * is currently down or a global grab is in effect.
+ * Note: 0 means variable is set to NULL, 1 means variable is set to some
+ * window, b/g means the variable is set to a window if a button is currently
+ * down or a global grab is in effect.
*
- * The final complication to all of this is enter and leave events.
- * In order to correctly handle all of the various cases, Tk cannot
- * rely on X enter/leave events in all situations. The following
- * describes the correct sequence of enter and leave events that
- * should be observed by Tk scripts:
+ * The final complication to all of this is enter and leave events. In order
+ * to correctly handle all of the various cases, Tk cannot rely on X
+ * enter/leave events in all situations. The following describes the correct
+ * sequence of enter and leave events that should be observed by Tk scripts:
*
* Event(state) Enter/Leave From -> To
* ------------ ----------------------
@@ -82,13 +79,13 @@
* Ungrab(G): anc(grab window, event window) -> event window
* Ungrab(GB): restrict window -> event window
*
- * Note: anc(x,y) returns the least ancestor of y that is in the tree
- * of x, terminating at toplevels.
+ * Note: anc(x,y) returns the least ancestor of y that is in the tree of x,
+ * terminating at toplevels.
*/
/*
- * The following structure is used to pass information to
- * GrabRestrictProc from EatGrabEvents.
+ * The following structure is used to pass information to GrabRestrictProc
+ * from EatGrabEvents.
*/
typedef struct {
@@ -101,47 +98,46 @@ typedef struct {
*
* GRAB_GLOBAL 1 means this is a global grab (we grabbed via
* the server so all applications are locked out).
- * 0 means this is a local grab that affects
- * only this application.
+ * 0 means this is a local grab that affects only
+ * this application.
* GRAB_TEMP_GLOBAL 1 means we've temporarily grabbed via the
- * server because a button is down and we want
- * to make sure that we get the button-up
- * event. The grab will be released when the
- * last mouse button goes up.
+ * server because a button is down and we want to
+ * make sure that we get the button-up event. The
+ * grab will be released when the last mouse
+ * button goes up.
*/
#define GRAB_GLOBAL 1
#define GRAB_TEMP_GLOBAL 4
/*
- * The following structure is a Tcl_Event that triggers a change in
- * the grabWinPtr field of a display. This event guarantees that
- * the change occurs in the proper order relative to enter and leave
- * events.
+ * The following structure is a Tcl_Event that triggers a change in the
+ * grabWinPtr field of a display. This event guarantees that the change occurs
+ * in the proper order relative to enter and leave events.
*/
typedef struct NewGrabWinEvent {
Tcl_Event header; /* Standard information for all Tcl events. */
TkDisplay *dispPtr; /* Display whose grab window is to change. */
- Window grabWindow; /* New grab window for display. This is
+ Window grabWindow; /* New grab window for display. This is
* recorded instead of a (TkWindow *) because
- * it will allow us to detect cases where
- * the window is destroyed before this event
- * is processed. */
+ * it will allow us to detect cases where the
+ * window is destroyed before this event is
+ * processed. */
} NewGrabWinEvent;
/*
* The following magic value is stored in the "send_event" field of
- * EnterNotify and LeaveNotify events that are generated in this
- * file. This allows us to separate "real" events coming from the
- * server from those that we generated.
+ * EnterNotify and LeaveNotify events that are generated in this file. This
+ * allows us to separate "real" events coming from the server from those that
+ * we generated.
*/
#define GENERATED_EVENT_MAGIC ((Bool) 0x147321ac)
/*
- * Mask that selects any of the state bits corresponding to buttons,
- * plus masks that select individual buttons' bits:
+ * Mask that selects any of the state bits corresponding to buttons, plus
+ * masks that select individual buttons' bits:
*/
#define ALL_BUTTONS \
@@ -151,32 +147,27 @@ static unsigned int buttonStates[] = {
};
/*
- * Forward declarations for procedures declared later in this file:
+ * Forward declarations for functions declared later in this file:
*/
-static void EatGrabEvents _ANSI_ARGS_((TkDisplay *dispPtr,
- unsigned int serial));
-static TkWindow * FindCommonAncestor _ANSI_ARGS_((TkWindow *winPtr1,
- TkWindow *winPtr2, int *countPtr1,
- int *countPtr2));
-static Tk_RestrictAction GrabRestrictProc _ANSI_ARGS_((ClientData arg,
- XEvent *eventPtr));
-static int GrabWinEventProc _ANSI_ARGS_((Tcl_Event *evPtr,
- int flags));
-static void MovePointer2 _ANSI_ARGS_((TkWindow *sourcePtr,
- TkWindow *destPtr, int mode, int leaveEvents,
- int EnterEvents));
-static void QueueGrabWindowChange _ANSI_ARGS_((TkDisplay *dispPtr,
- TkWindow *grabWinPtr));
-static void ReleaseButtonGrab _ANSI_ARGS_((TkDisplay *dispPtr));
+static void EatGrabEvents(TkDisplay *dispPtr, unsigned int serial);
+static TkWindow * FindCommonAncestor(TkWindow *winPtr1,
+ TkWindow *winPtr2, int *countPtr1, int *countPtr2);
+static Tk_RestrictAction GrabRestrictProc(ClientData arg, XEvent *eventPtr);
+static int GrabWinEventProc(Tcl_Event *evPtr, int flags);
+static void MovePointer2(TkWindow *sourcePtr, TkWindow *destPtr,
+ int mode, int leaveEvents, int EnterEvents);
+static void QueueGrabWindowChange(TkDisplay *dispPtr,
+ TkWindow *grabWinPtr);
+static void ReleaseButtonGrab(TkDisplay *dispPtr);
/*
*----------------------------------------------------------------------
*
* Tk_GrabObjCmd --
*
- * This procedure is invoked to process the "grab" Tcl command.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the "grab" Tcl command. See the
+ * user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -189,12 +180,11 @@ static void ReleaseButtonGrab _ANSI_ARGS_((TkDisplay *dispPtr));
/* ARGSUSED */
int
-Tk_GrabObjCmd(clientData, interp, objc, objv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
+Tk_GrabObjCmd(
+ ClientData clientData, /* Main window associated with interpreter. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST objv[]) /* Argument objects. */
{
int globalGrab;
Tk_Window tkwin;
@@ -202,14 +192,16 @@ Tk_GrabObjCmd(clientData, interp, objc, objv)
char *arg;
int index;
int len;
- static CONST char *optionStrings[] = { "current", "release",
- "set", "status", (char *) NULL };
-
- static CONST char *flagStrings[] = { "-global", (char *) NULL };
-
- enum options { GRABCMD_CURRENT, GRABCMD_RELEASE,
- GRABCMD_SET, GRABCMD_STATUS };
-
+ static CONST char *optionStrings[] = {
+ "current", "release", "set", "status", NULL
+ };
+ static CONST char *flagStrings[] = {
+ "-global", NULL
+ };
+ enum options {
+ GRABCMD_CURRENT, GRABCMD_RELEASE, GRABCMD_SET, GRABCMD_STATUS
+ };
+
if (objc < 2) {
/*
* Can't use Tcl_WrongNumArgs here because we want the message to
@@ -223,8 +215,7 @@ Tk_GrabObjCmd(clientData, interp, objc, objv)
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "wrong # args: should be \"",
Tcl_GetString(objv[0]), " ?-global? window\" or \"",
- Tcl_GetString(objv[0]), " option ?arg arg ...?\"",
- (char *) NULL);
+ Tcl_GetString(objv[0]), " option ?arg arg ...?\"", NULL);
return TCL_ERROR;
}
@@ -264,115 +255,114 @@ Tk_GrabObjCmd(clientData, interp, objc, objv)
}
/*
- * First argument is not a window name and not "-global", find out
- * which option it is.
+ * First argument is not a window name and not "-global", find out which
+ * option it is.
*/
if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
&index) != TCL_OK) {
return TCL_ERROR;
}
-
+
switch ((enum options) index) {
- case GRABCMD_CURRENT: {
- /* [grab current ?window?] */
- if (objc > 3) {
- Tcl_WrongNumArgs(interp, 1, objv, "current ?window?");
+ case GRABCMD_CURRENT:
+ /* [grab current ?window?] */
+ if (objc > 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "current ?window?");
+ return TCL_ERROR;
+ }
+ if (objc == 3) {
+ tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]),
+ (Tk_Window) clientData);
+ if (tkwin == NULL) {
return TCL_ERROR;
}
- if (objc == 3) {
- tkwin = Tk_NameToWindow(interp,
- Tcl_GetString(objv[2]), (Tk_Window) clientData);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- dispPtr = ((TkWindow *) tkwin)->dispPtr;
+ dispPtr = ((TkWindow *) tkwin)->dispPtr;
+ if (dispPtr->eventualGrabWinPtr != NULL) {
+ Tcl_SetResult(interp, dispPtr->eventualGrabWinPtr->pathName,
+ TCL_STATIC);
+ }
+ } else {
+ for (dispPtr = TkGetDisplayList(); dispPtr != NULL;
+ dispPtr = dispPtr->nextPtr) {
if (dispPtr->eventualGrabWinPtr != NULL) {
- Tcl_SetResult(interp,
- dispPtr->eventualGrabWinPtr->pathName, TCL_STATIC);
- }
- } else {
- for (dispPtr = TkGetDisplayList(); dispPtr != NULL;
- dispPtr = dispPtr->nextPtr) {
- if (dispPtr->eventualGrabWinPtr != NULL) {
- Tcl_AppendElement(interp,
- dispPtr->eventualGrabWinPtr->pathName);
- }
+ Tcl_AppendElement(interp,
+ dispPtr->eventualGrabWinPtr->pathName);
}
}
- return TCL_OK;
}
+ return TCL_OK;
- case GRABCMD_RELEASE: {
- /* [grab release window] */
- if (objc != 3) {
- Tcl_WrongNumArgs(interp, 1, objv, "release window");
- return TCL_ERROR;
- }
- tkwin = Tk_NameToWindow(interp,
- Tcl_GetString(objv[2]), (Tk_Window) clientData);
- if (tkwin == NULL) {
- Tcl_ResetResult(interp);
- } else {
- Tk_Ungrab(tkwin);
- }
- break;
+ case GRABCMD_RELEASE:
+ /* [grab release window] */
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "release window");
+ return TCL_ERROR;
}
-
- case GRABCMD_SET: {
- /* [grab set ?-global? window] */
- if ((objc != 3) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 1, objv, "set ?-global? window");
- return TCL_ERROR;
- }
- if (objc == 3) {
- globalGrab = 0;
- tkwin = Tk_NameToWindow(interp,
- Tcl_GetString(objv[2]), (Tk_Window) clientData);
- } else {
- globalGrab = 1;
- /*
- * We could just test the argument by hand instead of using
- * Tcl_GetIndexFromObj; the benefit of using the function is
- * that it sets up the error message for us, so we are
- * certain to be consistant with the rest of Tcl.
- */
- if (Tcl_GetIndexFromObj(interp, objv[2], flagStrings, "option",
- 0, &index) != TCL_OK) {
- return TCL_ERROR;
- }
- tkwin = Tk_NameToWindow(interp,
- Tcl_GetString(objv[3]), (Tk_Window) clientData);
- }
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- return Tk_Grab(interp, tkwin, globalGrab);
+ tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]),
+ (Tk_Window) clientData);
+ if (tkwin == NULL) {
+ Tcl_ResetResult(interp);
+ } else {
+ Tk_Ungrab(tkwin);
}
+ break;
- case GRABCMD_STATUS: {
- /* [grab status window] */
- TkWindow *winPtr;
+ case GRABCMD_SET:
+ /* [grab set ?-global? window] */
+ if ((objc != 3) && (objc != 4)) {
+ Tcl_WrongNumArgs(interp, 1, objv, "set ?-global? window");
+ return TCL_ERROR;
+ }
+ if (objc == 3) {
+ globalGrab = 0;
+ tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]),
+ (Tk_Window) clientData);
+ } else {
+ globalGrab = 1;
- if (objc != 3) {
- Tcl_WrongNumArgs(interp, 1, objv, "status window");
- return TCL_ERROR;
- }
- winPtr = (TkWindow *) Tk_NameToWindow(interp,
- Tcl_GetString(objv[2]), (Tk_Window) clientData);
- if (winPtr == NULL) {
+ /*
+ * We could just test the argument by hand instead of using
+ * Tcl_GetIndexFromObj; the benefit of using the function is that
+ * it sets up the error message for us, so we are certain to be
+ * consistant with the rest of Tcl.
+ */
+
+ if (Tcl_GetIndexFromObj(interp, objv[2], flagStrings, "option",
+ 0, &index) != TCL_OK) {
return TCL_ERROR;
}
- dispPtr = winPtr->dispPtr;
- if (dispPtr->eventualGrabWinPtr != winPtr) {
- Tcl_SetResult(interp, "none", TCL_STATIC);
- } else if (dispPtr->grabFlags & GRAB_GLOBAL) {
- Tcl_SetResult(interp, "global", TCL_STATIC);
- } else {
- Tcl_SetResult(interp, "local", TCL_STATIC);
- }
- break;
+ tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[3]),
+ (Tk_Window) clientData);
+ }
+ if (tkwin == NULL) {
+ return TCL_ERROR;
+ }
+ return Tk_Grab(interp, tkwin, globalGrab);
+
+ case GRABCMD_STATUS: {
+ /* [grab status window] */
+ TkWindow *winPtr;
+
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 1, objv, "status window");
+ return TCL_ERROR;
+ }
+ winPtr = (TkWindow *) Tk_NameToWindow(interp, Tcl_GetString(objv[2]),
+ (Tk_Window) clientData);
+ if (winPtr == NULL) {
+ return TCL_ERROR;
+ }
+ dispPtr = winPtr->dispPtr;
+ if (dispPtr->eventualGrabWinPtr != winPtr) {
+ Tcl_SetResult(interp, "none", TCL_STATIC);
+ } else if (dispPtr->grabFlags & GRAB_GLOBAL) {
+ Tcl_SetResult(interp, "global", TCL_STATIC);
+ } else {
+ Tcl_SetResult(interp, "local", TCL_STATIC);
}
+ break;
+ }
}
return TCL_OK;
@@ -383,34 +373,32 @@ Tk_GrabObjCmd(clientData, interp, objc, objv)
*
* Tk_Grab --
*
- * Grabs the pointer and keyboard, so that mouse-related events are
- * only reported relative to a given window and its descendants.
+ * Grabs the pointer and keyboard, so that mouse-related events are only
+ * reported relative to a given window and its descendants.
*
* Results:
- * A standard Tcl result is returned. TCL_OK is the normal return
- * value; if the grab could not be set then TCL_ERROR is returned
- * and the interp's result will hold an error message.
+ * A standard Tcl result is returned. TCL_OK is the normal return value;
+ * if the grab could not be set then TCL_ERROR is returned and the
+ * interp's result will hold an error message.
*
* Side effects:
- * Once this call completes successfully, no window outside the
- * tree rooted at tkwin will receive pointer- or keyboard-related
- * events until the next call to Tk_Ungrab. If a previous grab was
- * in effect within this application, then it is replaced with a new
- * one.
+ * Once this call completes successfully, no window outside the tree
+ * rooted at tkwin will receive pointer- or keyboard-related events until
+ * the next call to Tk_Ungrab. If a previous grab was in effect within
+ * this application, then it is replaced with a new one.
*
*----------------------------------------------------------------------
*/
int
-Tk_Grab(interp, tkwin, grabGlobal)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_Window tkwin; /* Window on whose behalf the pointer
- * is to be grabbed. */
- int grabGlobal; /* Non-zero means issue a grab to the
- * server so that no other application
- * gets mouse or keyboard events.
- * Zero means the grab only applies
- * within this application. */
+Tk_Grab(
+ Tcl_Interp *interp, /* Used for error reporting. */
+ Tk_Window tkwin, /* Window on whose behalf the pointer is to be
+ * grabbed. */
+ int grabGlobal) /* Non-zero means issue a grab to the server
+ * so that no other application gets mouse or
+ * keyboard events. Zero means the grab only
+ * applies within this application. */
{
int grabResult, numTries;
TkWindow *winPtr = (TkWindow *) tkwin;
@@ -425,7 +413,7 @@ Tk_Grab(interp, tkwin, grabGlobal)
return TCL_OK;
}
if (dispPtr->eventualGrabWinPtr->mainPtr != winPtr->mainPtr) {
- alreadyGrabbed:
+ alreadyGrabbed:
Tcl_SetResult(interp, "grab failed: another application has grab",
TCL_STATIC);
return TCL_ERROR;
@@ -440,11 +428,11 @@ Tk_Grab(interp, tkwin, grabGlobal)
unsigned int state;
/*
- * Local grab. However, if any mouse buttons are down, turn
- * it into a global grab temporarily, until the last button
- * goes up. This does two things: (a) it makes sure that we
- * see the button-up event; and (b) it allows us to track mouse
- * motion among all of the windows of this application.
+ * Local grab. However, if any mouse buttons are down, turn it into a
+ * global grab temporarily, until the last button goes up. This does
+ * two things: (a) it makes sure that we see the button-up event; and
+ * (b) it allows us to track mouse motion among all of the windows of
+ * this application.
*/
dispPtr->grabFlags &= ~(GRAB_GLOBAL|GRAB_TEMP_GLOBAL);
@@ -456,30 +444,28 @@ Tk_Grab(interp, tkwin, grabGlobal)
}
} else {
dispPtr->grabFlags |= GRAB_GLOBAL;
- setGlobalGrab:
+ setGlobalGrab:
/*
- * Tricky point: must ungrab before grabbing. This is needed
- * in case there is a button auto-grab already in effect. If
- * there is, and the mouse has moved to a different window, X
- * won't generate enter and leave events to move the mouse if
- * we grab without ungrabbing.
+ * Tricky point: must ungrab before grabbing. This is needed in case
+ * there is a button auto-grab already in effect. If there is, and the
+ * mouse has moved to a different window, X won't generate enter and
+ * leave events to move the mouse if we grab without ungrabbing.
*/
XUngrabPointer(dispPtr->display, CurrentTime);
serial = NextRequest(dispPtr->display);
/*
- * Another tricky point: there are races with some window
- * managers that can cause grabs to fail because the window
- * manager hasn't released its grab quickly enough. To work
- * around this problem, retry a few times after AlreadyGrabbed
- * errors to give the grab release enough time to register with
- * the server.
+ * Another tricky point: there are races with some window managers
+ * that can cause grabs to fail because the window manager hasn't
+ * released its grab quickly enough. To work around this problem,
+ * retry a few times after AlreadyGrabbed errors to give the grab
+ * release enough time to register with the server.
*/
- grabResult = 0; /* Needed only to prevent gcc
- * compiler warnings. */
+ grabResult = 0; /* Needed only to prevent gcc compiler
+ * warnings. */
for (numTries = 0; numTries < 10; numTries++) {
grabResult = XGrabPointer(dispPtr->display, winPtr->window,
True, ButtonPressMask|ButtonReleaseMask|ButtonMotionMask
@@ -491,7 +477,7 @@ Tk_Grab(interp, tkwin, grabGlobal)
Tcl_Sleep(100);
}
if (grabResult != 0) {
- grabError:
+ grabError:
if (grabResult == GrabNotViewable) {
Tcl_SetResult(interp, "grab failed: window not viewable",
TCL_STATIC);
@@ -505,10 +491,10 @@ Tk_Grab(interp, tkwin, grabGlobal)
TCL_STATIC);
} else {
char msg[64 + TCL_INTEGER_SPACE];
-
+
sprintf(msg, "grab failed for unknown reason (code %d)",
grabResult);
- Tcl_AppendResult(interp, msg, (char *) NULL);
+ Tcl_AppendResult(interp, msg, NULL);
}
return TCL_ERROR;
}
@@ -521,13 +507,13 @@ Tk_Grab(interp, tkwin, grabGlobal)
/*
* Eat up any grab-related events generated by the server for the
- * grab. There are several reasons for doing this:
+ * grab. There are several reasons for doing this:
*
* 1. We have to synthesize the events for local grabs anyway, since
* the server doesn't participate in them.
* 2. The server doesn't always generate the right events for global
- * grabs (e.g. it generates events even if the current window is
- * in the grab tree, which we don't want).
+ * grabs (e.g. it generates events even if the current window is in
+ * the grab tree, which we don't want).
* 3. We want all the grab-related events to be processed immediately
* (before other events that are already queued); events coming
* from the server will be in the wrong place, but events we
@@ -538,8 +524,8 @@ Tk_Grab(interp, tkwin, grabGlobal)
}
/*
- * Synthesize leave events to move the pointer from its current window
- * up to the lowest ancestor that it has in common with the grab window.
+ * Synthesize leave events to move the pointer from its current window up
+ * to the lowest ancestor that it has in common with the grab window.
* However, only do this if the pointer is outside the grab window's
* subtree but inside the grab window's application.
*/
@@ -565,8 +551,8 @@ Tk_Grab(interp, tkwin, grabGlobal)
*
* Tk_Ungrab --
*
- * Releases a grab on the mouse pointer and keyboard, if there
- * is one set on the specified window.
+ * Releases a grab on the mouse pointer and keyboard, if there is one set
+ * on the specified window.
*
* Results:
* None.
@@ -579,9 +565,8 @@ Tk_Grab(interp, tkwin, grabGlobal)
*/
void
-Tk_Ungrab(tkwin)
- Tk_Window tkwin; /* Window whose grab should be
- * released. */
+Tk_Ungrab(
+ Tk_Window tkwin) /* Window whose grab should be released. */
{
TkDisplay *dispPtr;
TkWindow *grabWinPtr, *winPtr;
@@ -593,7 +578,7 @@ Tk_Ungrab(tkwin)
return;
}
ReleaseButtonGrab(dispPtr);
- QueueGrabWindowChange(dispPtr, (TkWindow *) NULL);
+ QueueGrabWindowChange(dispPtr, NULL);
if (dispPtr->grabFlags & (GRAB_GLOBAL|GRAB_TEMP_GLOBAL)) {
dispPtr->grabFlags &= ~(GRAB_GLOBAL|GRAB_TEMP_GLOBAL);
serial = NextRequest(dispPtr->display);
@@ -603,17 +588,17 @@ Tk_Ungrab(tkwin)
}
/*
- * Generate events to move the pointer back to the window where it
- * really is. Some notes:
- * 1. As with grabs, only do this if the "real" window is not a
- * descendant of the grab window, since in this case the pointer
- * is already where it's supposed to be.
+ * Generate events to move the pointer back to the window where it really
+ * is. Some notes:
+ * 1. As with grabs, only do this if the "real" window is not a descendant
+ * of the grab window, since in this case the pointer is already where
+ * it's supposed to be.
* 2. If the "real" window is in some other application then don't
- * generate any events at all, since everything's already been
- * reported correctly.
- * 3. Only generate enter events. Don't generate leave events,
- * because we never told the lower-level windows that they
- * had the pointer in the first place.
+ * generate any events at all, since everything's already been reported
+ * correctly.
+ * 3. Only generate enter events. Don't generate leave events, because we
+ * never told the lower-level windows that they had the pointer in the
+ * first place.
*/
for (winPtr = dispPtr->serverWinPtr; ; winPtr = winPtr->parentPtr) {
@@ -636,26 +621,26 @@ Tk_Ungrab(tkwin)
*
* ReleaseButtonGrab --
*
- * This procedure is called to release a simulated button grab, if
- * there is one in effect. A button grab is present whenever
- * dispPtr->buttonWinPtr is non-NULL or when the GRAB_TEMP_GLOBAL
- * flag is set.
+ * This function is called to release a simulated button grab, if there
+ * is one in effect. A button grab is present whenever
+ * dispPtr->buttonWinPtr is non-NULL or when the GRAB_TEMP_GLOBAL flag is
+ * set.
*
* Results:
* None.
*
* Side effects:
- * DispPtr->buttonWinPtr is reset to NULL, and enter and leave
- * events are generated if necessary to move the pointer from
- * the button grab window to its current window.
+ * DispPtr->buttonWinPtr is reset to NULL, and enter and leave events are
+ * generated if necessary to move the pointer from the button grab window
+ * to its current window.
*
*----------------------------------------------------------------------
*/
static void
-ReleaseButtonGrab(dispPtr)
- register TkDisplay *dispPtr; /* Display whose button grab is to be
- * released. */
+ReleaseButtonGrab(
+ register TkDisplay *dispPtr)/* Display whose button grab is to be
+ * released. */
{
unsigned int serial;
@@ -680,64 +665,64 @@ ReleaseButtonGrab(dispPtr)
*
* TkPointerEvent --
*
- * This procedure is called for each pointer-related event, before
- * the event has been processed. It does various things to make
- * grabs work correctly.
+ * This function is called for each pointer-related event, before the
+ * event has been processed. It does various things to make grabs work
+ * correctly.
*
* Results:
- * If the return value is 1 it means the event should be processed
- * (event handlers should be invoked). If the return value is 0
- * it means the event should be ignored in order to make grabs
- * work correctly. In some cases this procedure modifies the event.
+ * If the return value is 1 it means the event should be processed (event
+ * handlers should be invoked). If the return value is 0 it means the
+ * event should be ignored in order to make grabs work correctly. In some
+ * cases this function modifies the event.
*
* Side effects:
- * Grab state information may be updated. New events may also be
- * pushed back onto the event queue to replace or augment the
- * one passed in here.
+ * Grab state information may be updated. New events may also be pushed
+ * back onto the event queue to replace or augment the one passed in
+ * here.
*
*----------------------------------------------------------------------
*/
int
-TkPointerEvent(eventPtr, winPtr)
- register XEvent *eventPtr; /* Pointer to the event. */
- TkWindow *winPtr; /* Tk's information for window
- * where event was reported. */
+TkPointerEvent(
+ register XEvent *eventPtr, /* Pointer to the event. */
+ TkWindow *winPtr) /* Tk's information for window where event was
+ * reported. */
{
register TkWindow *winPtr2;
TkDisplay *dispPtr = winPtr->dispPtr;
unsigned int serial;
int outsideGrabTree = 0;
int ancestorOfGrab = 0;
- int appGrabbed = 0; /* Non-zero means event is being
- * reported to an application that is
- * affected by the grab. */
+ int appGrabbed = 0; /* Non-zero means event is being reported to
+ * an application that is affected by the
+ * grab. */
/*
* Collect information about the grab (if any).
*/
switch (TkGrabState(winPtr)) {
- case TK_GRAB_IN_TREE:
- appGrabbed = 1;
- break;
- case TK_GRAB_ANCESTOR:
- appGrabbed = 1;
- outsideGrabTree = 1;
- ancestorOfGrab = 1;
- break;
- case TK_GRAB_EXCLUDED:
- appGrabbed = 1;
- outsideGrabTree = 1;
- break;
+ case TK_GRAB_IN_TREE:
+ appGrabbed = 1;
+ break;
+ case TK_GRAB_ANCESTOR:
+ appGrabbed = 1;
+ outsideGrabTree = 1;
+ ancestorOfGrab = 1;
+ break;
+ case TK_GRAB_EXCLUDED:
+ appGrabbed = 1;
+ outsideGrabTree = 1;
+ break;
}
if ((eventPtr->type == EnterNotify) || (eventPtr->type == LeaveNotify)) {
/*
- * Keep track of what window the mouse is *really* over.
- * Any events that we generate have a special send_event value,
- * which is detected below and used to ignore the event for
- * purposes of setting serverWinPtr.
+ * Keep track of what window the mouse is *really* over. Any events
+ * that we generate have a special send_event value, which is detected
+ * below and used to ignore the event for purposes of setting
+ * serverWinPtr.
*/
if (eventPtr->xcrossing.send_event != GENERATED_EVENT_MAGIC) {
@@ -750,13 +735,13 @@ TkPointerEvent(eventPtr, winPtr)
}
/*
- * When a grab is active, X continues to report enter and leave
- * events for windows outside the tree of the grab window:
- * 1. Detect these events and ignore them except for
- * windows above the grab window.
- * 2. Allow Enter and Leave events to pass through the
- * windows above the grab window, but never let them
- * end up with the pointer *in* one of those windows.
+ * When a grab is active, X continues to report enter and leave events
+ * for windows outside the tree of the grab window:
+ * 1. Detect these events and ignore them except for windows above the
+ * grab window.
+ * 2. Allow Enter and Leave events to pass through the windows above
+ * the grab window, but never let them end up with the pointer *in*
+ * one of those windows.
*/
if (dispPtr->grabWinPtr != NULL) {
@@ -765,22 +750,21 @@ TkPointerEvent(eventPtr, winPtr)
return 0;
}
switch (eventPtr->xcrossing.detail) {
- case NotifyInferior:
- return 0;
- case NotifyAncestor:
- eventPtr->xcrossing.detail = NotifyVirtual;
- break;
- case NotifyNonlinear:
- eventPtr->xcrossing.detail = NotifyNonlinearVirtual;
- break;
+ case NotifyInferior:
+ return 0;
+ case NotifyAncestor:
+ eventPtr->xcrossing.detail = NotifyVirtual;
+ break;
+ case NotifyNonlinear:
+ eventPtr->xcrossing.detail = NotifyNonlinearVirtual;
+ break;
}
}
/*
- * Make buttons have the same grab-like behavior inside a grab
- * as they do outside a grab: do this by ignoring enter and
- * leave events except for the window in which the button was
- * pressed.
+ * Make buttons have the same grab-like behavior inside a grab as
+ * they do outside a grab: do this by ignoring enter and leave
+ * events except for the window in which the button was pressed.
*/
if ((dispPtr->buttonWinPtr != NULL)
@@ -798,12 +782,12 @@ TkPointerEvent(eventPtr, winPtr)
if (eventPtr->type == MotionNotify) {
/*
* When grabs are active, X reports motion events relative to the
- * window under the pointer. Instead, it should report the events
+ * window under the pointer. Instead, it should report the events
* relative to the window the button went down in, if there is a
- * button down. Otherwise, if the pointer window is outside the
- * subtree of the grab window, the events should be reported
- * relative to the grab window. Otherwise, the event should be
- * reported to the pointer window.
+ * button down. Otherwise, if the pointer window is outside the
+ * subtree of the grab window, the events should be reported relative
+ * to the grab window. Otherwise, the event should be reported to the
+ * pointer window.
*/
winPtr2 = winPtr;
@@ -822,32 +806,32 @@ TkPointerEvent(eventPtr, winPtr)
/*
* Process ButtonPress and ButtonRelease events:
- * 1. Keep track of whether a button is down and what window it
- * went down in.
- * 2. If the first button goes down outside the grab tree, pretend
- * it went down in the grab window. Note: it's important to
- * redirect events to the grab window like this in order to make
- * things like menus work, where button presses outside the
- * grabbed menu need to be seen. An application can always
- * ignore the events if they occur outside its window.
- * 3. If a button press or release occurs outside the window where
- * the first button was pressed, retarget the event so it's reported
- * to the window where the first button was pressed.
- * 4. If the last button is released in a window different than where
- * the first button was pressed, generate Enter/Leave events to
- * move the mouse from the button window to its current window.
- * 5. If the grab is set at a time when a button is already down, or
- * if the window where the button was pressed was deleted, then
- * dispPtr->buttonWinPtr will stay NULL. Just forget about the
- * auto-grab for the button press; events will go to whatever
- * window contains the pointer. If this window isn't in the grab
- * tree then redirect events to the grab window.
- * 6. When a button is pressed during a local grab, the X server sets
- * a grab of its own, since it doesn't even know about our local
- * grab. This causes enter and leave events no longer to be
- * generated in the same way as for global grabs. To eliminate this
- * problem, set a temporary global grab when the first button goes
- * down and release it when the last button comes up.
+ * 1. Keep track of whether a button is down and what window it went down
+ * in.
+ * 2. If the first button goes down outside the grab tree, pretend it went
+ * down in the grab window. Note: it's important to redirect events to
+ * the grab window like this in order to make things like menus work,
+ * where button presses outside the grabbed menu need to be seen. An
+ * application can always ignore the events if they occur outside its
+ * window.
+ * 3. If a button press or release occurs outside the window where the
+ * first button was pressed, retarget the event so it's reported to the
+ * window where the first button was pressed.
+ * 4. If the last button is released in a window different than where the
+ * first button was pressed, generate Enter/Leave events to move the
+ * mouse from the button window to its current window.
+ * 5. If the grab is set at a time when a button is already down, or if
+ * the window where the button was pressed was deleted, then
+ * dispPtr->buttonWinPtr will stay NULL. Just forget about the
+ * auto-grab for the button press; events will go to whatever window
+ * contains the pointer. If this window isn't in the grab tree then
+ * redirect events to the grab window.
+ * 6. When a button is pressed during a local grab, the X server sets a
+ * grab of its own, since it doesn't even know about our local grab.
+ * This causes enter and leave events no longer to be generated in the
+ * same way as for global grabs. To eliminate this problem, set a
+ * temporary global grab when the first button goes down and release it
+ * when the last button comes up.
*/
if ((eventPtr->type == ButtonPress) || (eventPtr->type == ButtonRelease)) {
@@ -908,12 +892,12 @@ TkPointerEvent(eventPtr, winPtr)
* TkChangeEventWindow --
*
* Given an event and a new window to which the event should be
- * retargeted, modify fields of the event so that the event is
- * properly retargeted to the new window.
+ * retargeted, modify fields of the event so that the event is properly
+ * retargeted to the new window.
*
* Results:
- * The following fields of eventPtr are modified: window,
- * subwindow, x, y, same_screen.
+ * The following fields of eventPtr are modified: window, subwindow, x,
+ * y, same_screen.
*
* Side effects:
* None.
@@ -922,12 +906,12 @@ TkPointerEvent(eventPtr, winPtr)
*/
void
-TkChangeEventWindow(eventPtr, winPtr)
- register XEvent *eventPtr; /* Event to retarget. Must have
- * type ButtonPress, ButtonRelease, KeyPress,
- * KeyRelease, MotionNotify, EnterNotify,
- * or LeaveNotify. */
- TkWindow *winPtr; /* New target window for event. */
+TkChangeEventWindow(
+ register XEvent *eventPtr, /* Event to retarget. Must have type
+ * ButtonPress, ButtonRelease, KeyPress,
+ * KeyRelease, MotionNotify, EnterNotify, or
+ * LeaveNotify. */
+ TkWindow *winPtr) /* New target window for event. */
{
int x, y, sameScreen, bd;
register TkWindow *childPtr;
@@ -972,44 +956,44 @@ TkChangeEventWindow(eventPtr, winPtr)
*
* TkInOutEvents --
*
- * This procedure synthesizes EnterNotify and LeaveNotify events
- * to correctly transfer the pointer from one window to another.
- * It can also be used to generate FocusIn and FocusOut events
- * to move the input focus.
+ * This function synthesizes EnterNotify and LeaveNotify events to
+ * correctly transfer the pointer from one window to another. It can also
+ * be used to generate FocusIn and FocusOut events to move the input
+ * focus.
*
* Results:
* None.
*
* Side effects:
- * Synthesized events may be pushed back onto the event queue.
- * The event pointed to by eventPtr is modified.
+ * Synthesized events may be pushed back onto the event queue. The event
+ * pointed to by eventPtr is modified.
*
*----------------------------------------------------------------------
*/
void
-TkInOutEvents(eventPtr, sourcePtr, destPtr, leaveType, enterType, position)
- XEvent *eventPtr; /* A template X event. Must have all fields
+TkInOutEvents(
+ XEvent *eventPtr, /* A template X event. Must have all fields
* properly set except for type, window,
- * subwindow, x, y, detail, and same_screen
+ * subwindow, x, y, detail, and same_screen.
* (Not all of these fields are valid for
- * FocusIn/FocusOut events; x_root and y_root
+ * FocusIn/FocusOut events; x_root and y_root
* must be valid for Enter/Leave events, even
* though x and y needn't be valid). */
- TkWindow *sourcePtr; /* Window that used to have the pointer or
+ TkWindow *sourcePtr, /* Window that used to have the pointer or
* focus (NULL means it was not in a window
* managed by this process). */
- TkWindow *destPtr; /* Window that is to end up with the pointer
+ TkWindow *destPtr, /* Window that is to end up with the pointer
* or focus (NULL means it's not one managed
* by this process). */
- int leaveType; /* Type of events to generate for windows
- * being left (LeaveNotify or FocusOut). 0
+ int leaveType, /* Type of events to generate for windows
+ * being left (LeaveNotify or FocusOut). 0
* means don't generate leave events. */
- int enterType; /* Type of events to generate for windows
- * being entered (EnterNotify or FocusIn). 0
+ int enterType, /* Type of events to generate for windows
+ * being entered (EnterNotify or FocusIn). 0
* means don't generate enter events. */
- Tcl_QueuePosition position; /* Position at which events are added to
- * the system event queue. */
+ Tcl_QueuePosition position) /* Position at which events are added to the
+ * system event queue. */
{
register TkWindow *winPtr;
int upLevels, downLevels, i, j, focus;
@@ -1017,17 +1001,15 @@ TkInOutEvents(eventPtr, sourcePtr, destPtr, leaveType, enterType, position)
/*
* There are four possible cases to deal with:
*
- * 1. SourcePtr and destPtr are the same. There's nothing to do in
- * this case.
- * 2. SourcePtr is an ancestor of destPtr in the same top-level
- * window. Must generate events down the window tree from source
- * to dest.
- * 3. DestPtr is an ancestor of sourcePtr in the same top-level
- * window. Must generate events up the window tree from sourcePtr
- * to destPtr.
- * 4. All other cases. Must first generate events up the window tree
- * from sourcePtr to its top-level, then down from destPtr's
- * top-level to destPtr. This form is called "non-linear."
+ * 1. SourcePtr and destPtr are the same. There's nothing to do in this
+ * case.
+ * 2. SourcePtr is an ancestor of destPtr in the same top-level window.
+ * Must generate events down the window tree from source to dest.
+ * 3. DestPtr is an ancestor of sourcePtr in the same top-level window.
+ * Must generate events up the window tree from sourcePtr to destPtr.
+ * 4. All other cases. Must first generate events up the window tree from
+ * sourcePtr to its top-level, then down from destPtr's top-level to
+ * destPtr. This form is called "non-linear."
*
* The call to FindCommonAncestor separates these four cases and decides
* how many levels up and down events have to be generated for.
@@ -1047,7 +1029,6 @@ TkInOutEvents(eventPtr, sourcePtr, destPtr, leaveType, enterType, position)
* Generate enter/leave events and add them to the grab event queue.
*/
-
#define QUEUE(w, t, d) \
if (w->window != None) { \
eventPtr->type = t; \
@@ -1062,7 +1043,6 @@ TkInOutEvents(eventPtr, sourcePtr, destPtr, leaveType, enterType, position)
}
if (downLevels == 0) {
-
/*
* SourcePtr is an inferior of destPtr.
*/
@@ -1078,7 +1058,6 @@ TkInOutEvents(eventPtr, sourcePtr, destPtr, leaveType, enterType, position)
QUEUE(destPtr, enterType, NotifyInferior);
}
} else if (upLevels == 0) {
-
/*
* DestPtr is an inferior of sourcePtr.
*/
@@ -1090,6 +1069,7 @@ TkInOutEvents(eventPtr, sourcePtr, destPtr, leaveType, enterType, position)
for (i = downLevels-1; i > 0; i--) {
for (winPtr = destPtr->parentPtr, j = 1; j < i;
winPtr = winPtr->parentPtr, j++) {
+ /* empty */
}
QUEUE(winPtr, enterType, NotifyVirtual);
}
@@ -1098,9 +1078,8 @@ TkInOutEvents(eventPtr, sourcePtr, destPtr, leaveType, enterType, position)
}
}
} else {
-
/*
- * Non-linear: neither window is an inferior of the other.
+ * Non-linear: neither window is an inferior of the other.
*/
if (leaveType != 0) {
@@ -1129,11 +1108,11 @@ TkInOutEvents(eventPtr, sourcePtr, destPtr, leaveType, enterType, position)
*
* MovePointer2 --
*
- * This procedure synthesizes EnterNotify and LeaveNotify events
- * to correctly transfer the pointer from one window to another.
- * It is different from TkInOutEvents in that no template X event
- * needs to be supplied; this procedure generates the template
- * event and calls TkInOutEvents.
+ * This function synthesizes EnterNotify and LeaveNotify events to
+ * correctly transfer the pointer from one window to another. It is
+ * different from TkInOutEvents in that no template X event needs to be
+ * supplied; this function generates the template event and calls
+ * TkInOutEvents.
*
* Results:
* None.
@@ -1145,20 +1124,20 @@ TkInOutEvents(eventPtr, sourcePtr, destPtr, leaveType, enterType, position)
*/
static void
-MovePointer2(sourcePtr, destPtr, mode, leaveEvents, enterEvents)
- TkWindow *sourcePtr; /* Window currently containing pointer (NULL
+MovePointer2(
+ TkWindow *sourcePtr, /* Window currently containing pointer (NULL
* means it's not one managed by this
* process). */
- TkWindow *destPtr; /* Window that is to end up containing the
- * pointer (NULL means it's not one managed
- * by this process). */
- int mode; /* Mode for enter/leave events, such as
+ TkWindow *destPtr, /* Window that is to end up containing the
+ * pointer (NULL means it's not one managed by
+ * this process). */
+ int mode, /* Mode for enter/leave events, such as
* NotifyNormal or NotifyUngrab. */
- int leaveEvents; /* Non-zero means generate leave events for the
- * windows being left. Zero means don't
+ int leaveEvents, /* Non-zero means generate leave events for
+ * the windows being left. Zero means don't
* generate leave events. */
- int enterEvents; /* Non-zero means generate enter events for the
- * windows being entered. Zero means don't
+ int enterEvents) /* Non-zero means generate enter events for
+ * the windows being entered. Zero means don't
* generate enter events. */
{
XEvent event;
@@ -1174,12 +1153,10 @@ MovePointer2(sourcePtr, destPtr, mode, leaveEvents, enterEvents)
}
}
- event.xcrossing.serial = LastKnownRequestProcessed(
- winPtr->display);
+ event.xcrossing.serial = LastKnownRequestProcessed(winPtr->display);
event.xcrossing.send_event = GENERATED_EVENT_MAGIC;
event.xcrossing.display = winPtr->display;
- event.xcrossing.root = RootWindow(winPtr->display,
- winPtr->screenNum);
+ event.xcrossing.root = RootWindow(winPtr->display, winPtr->screenNum);
event.xcrossing.time = TkCurrentTime(winPtr->dispPtr);
XQueryPointer(winPtr->display, winPtr->window, &dummy1, &dummy2,
&event.xcrossing.x_root, &event.xcrossing.y_root,
@@ -1195,30 +1172,30 @@ MovePointer2(sourcePtr, destPtr, mode, leaveEvents, enterEvents)
*
* TkGrabDeadWindow --
*
- * This procedure is invoked whenever a window is deleted, so that
+ * This function is invoked whenever a window is deleted, so that
* grab-related cleanup can be performed.
*
* Results:
* None.
*
* Side effects:
- * Various cleanups happen, such as generating events to move the
- * pointer back to its "natural" window as if an ungrab had been
- * done. See the code.
+ * Various cleanups happen, such as generating events to move the pointer
+ * back to its "natural" window as if an ungrab had been done. See the
+ * code.
*
*----------------------------------------------------------------------
*/
void
-TkGrabDeadWindow(winPtr)
- register TkWindow *winPtr; /* Window that is in the process
- * of being deleted. */
+TkGrabDeadWindow(
+ register TkWindow *winPtr) /* Window that is in the process of being
+ * deleted. */
{
TkDisplay *dispPtr = winPtr->dispPtr;
if (dispPtr->eventualGrabWinPtr == winPtr) {
/*
- * Grab window was deleted. Release the grab.
+ * Grab window was deleted. Release the grab.
*/
Tk_Ungrab((Tk_Window) dispPtr->eventualGrabWinPtr);
@@ -1242,26 +1219,25 @@ TkGrabDeadWindow(winPtr)
*
* EatGrabEvents --
*
- * This procedure is called to eliminate any Enter, Leave,
- * FocusIn, or FocusOut events in the event queue for a
- * display that have mode NotifyGrab or NotifyUngrab and
- * have a serial number no less than a given value and are not
- * generated by the grab module.
+ * This function is called to eliminate any Enter, Leave, FocusIn, or
+ * FocusOut events in the event queue for a display that have mode
+ * NotifyGrab or NotifyUngrab and have a serial number no less than a
+ * given value and are not generated by the grab module.
*
* Results:
* None.
*
* Side effects:
- * DispPtr's display gets sync-ed, and some of the events get
- * removed from the Tk event queue.
+ * DispPtr's display gets sync-ed, and some of the events get removed
+ * from the Tk event queue.
*
*----------------------------------------------------------------------
*/
static void
-EatGrabEvents(dispPtr, serial)
- TkDisplay *dispPtr; /* Display from which to consume events. */
- unsigned int serial; /* Only discard events that have a serial
+EatGrabEvents(
+ TkDisplay *dispPtr, /* Display from which to consume events. */
+ unsigned int serial) /* Only discard events that have a serial
* number at least this great. */
{
Tk_RestrictProc *oldProc;
@@ -1282,10 +1258,10 @@ EatGrabEvents(dispPtr, serial)
*
* GrabRestrictProc --
*
- * A Tk_RestrictProc used by EatGrabEvents to eliminate any
- * Enter, Leave, FocusIn, or FocusOut events in the event queue
- * for a display that has mode NotifyGrab or NotifyUngrab and
- * have a serial number no less than a given value.
+ * A Tk_RestrictProc used by EatGrabEvents to eliminate any Enter, Leave,
+ * FocusIn, or FocusOut events in the event queue for a display that has
+ * mode NotifyGrab or NotifyUngrab and have a serial number no less than
+ * a given value.
*
* Results:
* Returns either TK_DISCARD_EVENT or TK_DEFER_EVENT.
@@ -1297,17 +1273,17 @@ EatGrabEvents(dispPtr, serial)
*/
static Tk_RestrictAction
-GrabRestrictProc(arg, eventPtr)
- ClientData arg;
- XEvent *eventPtr;
+GrabRestrictProc(
+ ClientData arg,
+ XEvent *eventPtr)
{
GrabInfo *info = (GrabInfo *) arg;
int mode, diff;
/*
- * The diff caculation is trickier than it may seem. Don't forget
- * that serial numbers can wrap around, so can't compare the two
- * serial numbers directly.
+ * The diff caculation is trickier than it may seem. Don't forget that
+ * serial numbers can wrap around, so can't compare the two serial numbers
+ * directly.
*/
diff = eventPtr->xany.serial - info->serial;
@@ -1333,29 +1309,28 @@ GrabRestrictProc(arg, eventPtr)
*
* QueueGrabWindowChange --
*
- * This procedure queues a special event in the Tcl event queue,
- * which will cause the "grabWinPtr" field for the display to get
- * modified when the event is processed. This is needed to make
- * sure that the grab window changes at the proper time relative
- * to grab-related enter and leave events that are also in the
- * queue. In particular, this approach works even when multiple
- * grabs and ungrabs happen back-to-back.
+ * This function queues a special event in the Tcl event queue, which
+ * will cause the "grabWinPtr" field for the display to get modified when
+ * the event is processed. This is needed to make sure that the grab
+ * window changes at the proper time relative to grab-related enter and
+ * leave events that are also in the queue. In particular, this approach
+ * works even when multiple grabs and ungrabs happen back-to-back.
*
* Results:
* None.
*
* Side effects:
- * DispPtr->grabWinPtr will be modified later (by GrabWinEventProc)
- * when the event is removed from the grab event queue.
+ * DispPtr->grabWinPtr will be modified later (by GrabWinEventProc) when
+ * the event is removed from the grab event queue.
*
*----------------------------------------------------------------------
*/
static void
-QueueGrabWindowChange(dispPtr, grabWinPtr)
- TkDisplay *dispPtr; /* Display on which to change the grab
+QueueGrabWindowChange(
+ TkDisplay *dispPtr, /* Display on which to change the grab
* window. */
- TkWindow *grabWinPtr; /* Window that is to become the new grab
+ TkWindow *grabWinPtr) /* Window that is to become the new grab
* window (may be NULL). */
{
NewGrabWinEvent *grabEvPtr;
@@ -1377,25 +1352,25 @@ QueueGrabWindowChange(dispPtr, grabWinPtr)
*
* GrabWinEventProc --
*
- * This procedure is invoked as a handler for Tcl_Events of type
- * NewGrabWinEvent. It updates the current grab window field in
- * a display.
+ * This function is invoked as a handler for Tcl_Events of type
+ * NewGrabWinEvent. It updates the current grab window field in a
+ * display.
*
* Results:
- * Returns 1 if the event was processed, 0 if it should be deferred
- * for processing later.
+ * Returns 1 if the event was processed, 0 if it should be deferred for
+ * processing later.
*
* Side effects:
- * The grabWinPtr field is modified in the display associated with
- * the event.
+ * The grabWinPtr field is modified in the display associated with the
+ * event.
*
*----------------------------------------------------------------------
*/
static int
-GrabWinEventProc(evPtr, flags)
- Tcl_Event *evPtr; /* Event of type NewGrabWinEvent. */
- int flags; /* Flags argument to Tk_DoOneEvent: indicates
+GrabWinEventProc(
+ Tcl_Event *evPtr, /* Event of type NewGrabWinEvent. */
+ int flags) /* Flags argument to Tk_DoOneEvent: indicates
* what kinds of events are being processed
* right now. */
{
@@ -1411,19 +1386,19 @@ GrabWinEventProc(evPtr, flags)
*
* FindCommonAncestor --
*
- * Given two windows, this procedure finds their least common
- * ancestor and also computes how many levels up this ancestor
- * is from each of the original windows.
+ * Given two windows, this function finds their least common ancestor and
+ * also computes how many levels up this ancestor is from each of the
+ * original windows.
*
* Results:
- * If the windows are in different applications or top-level
- * windows, then NULL is returned and *countPtr1 and *countPtr2
- * are set to the depths of the two windows in their respective
- * top-level windows (1 means the window is a top-level, 2 means
- * its parent is a top-level, and so on). Otherwise, the return
- * value is a pointer to the common ancestor and the counts are
- * set to the distance of winPtr1 and winPtr2 from this ancestor
- * (1 means they're children, 2 means grand-children, etc.).
+ * If the windows are in different applications or top-level windows,
+ * then NULL is returned and *countPtr1 and *countPtr2 are set to the
+ * depths of the two windows in their respective top-level windows (1
+ * means the window is a top-level, 2 means its parent is a top-level,
+ * and so on). Otherwise, the return value is a pointer to the common
+ * ancestor and the counts are set to the distance of winPtr1 and winPtr2
+ * from this ancestor (1 means they're children, 2 means grand-children,
+ * etc.).
*
* Side effects:
* None.
@@ -1432,12 +1407,12 @@ GrabWinEventProc(evPtr, flags)
*/
static TkWindow *
-FindCommonAncestor(winPtr1, winPtr2, countPtr1, countPtr2)
- TkWindow *winPtr1; /* First window. May be NULL. */
- TkWindow *winPtr2; /* Second window. May be NULL. */
- int *countPtr1; /* Store nesting level of winPtr1 within
+FindCommonAncestor(
+ TkWindow *winPtr1, /* First window. May be NULL. */
+ TkWindow *winPtr2, /* Second window. May be NULL. */
+ int *countPtr1, /* Store nesting level of winPtr1 within
* common ancestor here. */
- int *countPtr2; /* Store nesting level of winPtr2 within
+ int *countPtr2) /* Store nesting level of winPtr2 within
* common ancestor here. */
{
register TkWindow *winPtr;
@@ -1458,8 +1433,8 @@ FindCommonAncestor(winPtr1, winPtr2, countPtr1, countPtr2)
}
/*
- * Search upwards from winPtr2 until an ancestor of winPtr1 is
- * found or a top-level window is reached.
+ * Search upwards from winPtr2 until an ancestor of winPtr1 is found or a
+ * top-level window is reached.
*/
winPtr = winPtr2;
@@ -1512,15 +1487,13 @@ FindCommonAncestor(winPtr1, winPtr2, countPtr1, countPtr2)
*
* TkPositionInTree --
*
- * Compute where the given window is relative to a particular
- * subtree of the window hierarchy.
+ * Compute where the given window is relative to a particular subtree of
+ * the window hierarchy.
*
* Results:
- *
- * Returns TK_GRAB_IN_TREE if the window is contained in the
- * subtree. Returns TK_GRAB_ANCESTOR if the window is an
- * ancestor of the subtree, in the same toplevel. Otherwise
- * it returns TK_GRAB_EXCLUDED.
+ * Returns TK_GRAB_IN_TREE if the window is contained in the subtree.
+ * Returns TK_GRAB_ANCESTOR if the window is an ancestor of the subtree,
+ * in the same toplevel. Otherwise it returns TK_GRAB_EXCLUDED.
*
* Side effects:
* None.
@@ -1529,9 +1502,9 @@ FindCommonAncestor(winPtr1, winPtr2, countPtr1, countPtr2)
*/
int
-TkPositionInTree(winPtr, treePtr)
- TkWindow *winPtr; /* Window to be checked. */
- TkWindow *treePtr; /* Root of tree to compare against. */
+TkPositionInTree(
+ TkWindow *winPtr, /* Window to be checked. */
+ TkWindow *treePtr) /* Root of tree to compare against. */
{
TkWindow *winPtr2;
@@ -1558,21 +1531,20 @@ TkPositionInTree(winPtr, treePtr)
*
* TkGrabState --
*
- * Given a window, this procedure returns a value that indicates
- * the grab state of the application relative to the window.
+ * Given a window, this function returns a value that indicates the grab
+ * state of the application relative to the window.
*
* Results:
* The return value is one of three things:
* TK_GRAB_NONE - no grab is in effect.
- * TK_GRAB_IN_TREE - there is a grab in effect, and winPtr
- * is in the grabbed subtree.
- * TK_GRAB_ANCESTOR - there is a grab in effect; winPtr is
- * an ancestor of the grabbed window, in
- * the same toplevel.
- * TK_GRAB_EXCLUDED - there is a grab in effect; winPtr is
- * outside the tree of the grab and is not
- * an ancestor of the grabbed window in the
- * same toplevel.
+ * TK_GRAB_IN_TREE - there is a grab in effect, and winPtr is in
+ * the grabbed subtree.
+ * TK_GRAB_ANCESTOR - there is a grab in effect; winPtr is an
+ * ancestor of the grabbed window, in the same
+ * toplevel.
+ * TK_GRAB_EXCLUDED - there is a grab in effect; winPtr is outside
+ * the tree of the grab and is not an ancestor of
+ * the grabbed window in the same toplevel.
*
* Side effects:
* None.
@@ -1581,8 +1553,8 @@ TkPositionInTree(winPtr, treePtr)
*/
int
-TkGrabState(winPtr)
- TkWindow *winPtr; /* Window for which grab information is
+TkGrabState(
+ TkWindow *winPtr) /* Window for which grab information is
* needed. */
{
TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr;
@@ -1597,3 +1569,11 @@ TkGrabState(winPtr)
return TkPositionInTree(winPtr, grabWinPtr);
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/generic/tkMacWinMenu.c b/generic/tkMacWinMenu.c
index ca77c45..fa8dff6 100644
--- a/generic/tkMacWinMenu.c
+++ b/generic/tkMacWinMenu.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkMacWinMenu.c --
*
* This module implements the common elements of the Mac and Windows
@@ -6,10 +6,10 @@
*
* 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: tkMacWinMenu.c,v 1.3 1999/04/16 01:51:19 stanton Exp $
+ * RCS: @(#) $Id: tkMacWinMenu.c,v 1.4 2005/11/14 22:44:11 dkf Exp $
*/
#include "tkMenu.h"
@@ -19,9 +19,7 @@ typedef struct ThreadSpecificData {
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
-
-static int PreprocessMenu _ANSI_ARGS_((TkMenu *menuPtr));
-
+static int PreprocessMenu(TkMenu *menuPtr);
/*
*----------------------------------------------------------------------
@@ -31,8 +29,8 @@ static int PreprocessMenu _ANSI_ARGS_((TkMenu *menuPtr));
* The guts of the preprocessing. Recursive.
*
* Results:
- * The return value is a standard Tcl result (errors can occur
- * while the postcommands are being processed).
+ * The return value is a standard Tcl result (errors can occur while the
+ * postcommands are being processed).
*
* Side effects:
* Since commands can get executed while this routine is being executed,
@@ -42,61 +40,59 @@ static int PreprocessMenu _ANSI_ARGS_((TkMenu *menuPtr));
*/
static int
-PreprocessMenu(menuPtr)
- TkMenu *menuPtr;
+PreprocessMenu(
+ TkMenu *menuPtr)
{
int index, result, finished;
- TkMenu *cascadeMenuPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
-
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
Tcl_Preserve((ClientData) menuPtr);
-
+
/*
* First, let's process the post command on ourselves. If this command
* destroys this menu, or if there was an error, we are done.
*/
-
+
result = TkPostCommand(menuPtr);
if ((result != TCL_OK) || (menuPtr->tkwin == NULL)) {
- goto done;
+ goto done;
}
-
+
/*
- * Now, we go through structure and process all of the commands.
- * Since the structure is changing, we stop after we do one command,
- * and start over. When we get through without doing any, we are done.
+ * Now, we go through structure and process all of the commands. Since the
+ * structure is changing, we stop after we do one command, and start over.
+ * When we get through without doing any, we are done.
*/
-
-
+
do {
- finished = 1;
- for (index = 0; index < menuPtr->numEntries; index++) {
- if ((menuPtr->entries[index]->type == CASCADE_ENTRY)
- && (menuPtr->entries[index]->namePtr != NULL)) {
- if ((menuPtr->entries[index]->childMenuRefPtr != NULL)
- && (menuPtr->entries[index]->childMenuRefPtr->menuPtr
- != NULL)) {
- cascadeMenuPtr =
- menuPtr->entries[index]->childMenuRefPtr->menuPtr;
- if (cascadeMenuPtr->postCommandGeneration !=
- tsdPtr->postCommandGeneration) {
- cascadeMenuPtr->postCommandGeneration =
- tsdPtr->postCommandGeneration;
- result = PreprocessMenu(cascadeMenuPtr);
- if (result != TCL_OK) {
- goto done;
- }
- finished = 0;
- break;
- }
- }
- }
- }
+ finished = 1;
+ for (index = 0; index < menuPtr->numEntries; index++) {
+ register TkMenuEntry *entryPtr = menuPtr->entries[index];
+
+ if ((entryPtr->type == CASCADE_ENTRY)
+ && (entryPtr->namePtr != NULL)
+ && (entryPtr->childMenuRefPtr != NULL)
+ && (entryPtr->childMenuRefPtr->menuPtr != NULL)) {
+ TkMenu *cascadeMenuPtr = entryPtr->childMenuRefPtr->menuPtr;
+
+ if (cascadeMenuPtr->postCommandGeneration !=
+ tsdPtr->postCommandGeneration) {
+ cascadeMenuPtr->postCommandGeneration =
+ tsdPtr->postCommandGeneration;
+ result = PreprocessMenu(cascadeMenuPtr);
+ if (result != TCL_OK) {
+ goto done;
+ }
+ finished = 0;
+ break;
+ }
+ }
+ }
} while (!finished);
-
- done:
- Tcl_Release((ClientData)menuPtr);
+
+ done:
+ Tcl_Release((ClientData) menuPtr);
return result;
}
@@ -105,23 +101,23 @@ PreprocessMenu(menuPtr)
*
* TkPreprocessMenu --
*
- * On the Mac and on Windows, all of the postcommand processing has
- * to be done on the entire tree underneath the main window to be
- * posted. This means that we have to traverse the menu tree and
- * issue the postcommands for all of the menus that have cascades
- * attached. Since the postcommands can change the menu structure while
- * we are traversing, we have to be extremely careful. Basically, the
- * idea is to traverse the structure until we succesfully process
- * one postcommand. Then we start over, and do it again until
- * we traverse the whole structure without processing any postcommands.
+ * On the Mac and on Windows, all of the postcommand processing has to be
+ * done on the entire tree underneath the main window to be posted. This
+ * means that we have to traverse the menu tree and issue the
+ * postcommands for all of the menus that have cascades attached. Since
+ * the postcommands can change the menu structure while we are
+ * traversing, we have to be extremely careful. Basically, the idea is to
+ * traverse the structure until we succesfully process one postcommand.
+ * Then we start over, and do it again until we traverse the whole
+ * structure without processing any postcommands.
*
- * We are also going to set up the cascade back pointers in here
- * since we have to traverse the entire structure underneath the menu
- * anyway, We can clear the postcommand marks while we do that.
+ * We are also going to set up the cascade back pointers in here since we
+ * have to traverse the entire structure underneath the menu anyway. We
+ * can clear the postcommand marks while we do that.
*
* Results:
- * The return value is a standard Tcl result (errors can occur
- * while the postcommands are being processed).
+ * The return value is a standard Tcl result (errors can occur while the
+ * postcommands are being processed).
*
* Side effects:
* Since commands can get executed while this routine is being executed,
@@ -131,13 +127,21 @@ PreprocessMenu(menuPtr)
*/
int
-TkPreprocessMenu(menuPtr)
- TkMenu *menuPtr;
+TkPreprocessMenu(
+ TkMenu *menuPtr)
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
tsdPtr->postCommandGeneration++;
menuPtr->postCommandGeneration = tsdPtr->postCommandGeneration;
return PreprocessMenu(menuPtr);
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/generic/tkMenu.h b/generic/tkMenu.h
index dc23478..630e748 100644
--- a/generic/tkMenu.h
+++ b/generic/tkMenu.h
@@ -1,14 +1,15 @@
/*
* tkMenu.h --
*
- * Declarations shared among all of the files that implement menu widgets.
+ * Declarations shared among all of the files that implement menu
+ * widgets.
*
* 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: tkMenu.h,v 1.9 2005/10/12 09:43:37 dkf Exp $
+ * RCS: @(#) $Id: tkMenu.h,v 1.10 2005/11/14 22:44:11 dkf Exp $
*/
#ifndef _TKMENU
@@ -39,26 +40,28 @@ typedef struct TkMenuPlatformData_ *TkMenuPlatformData;
typedef struct TkMenuPlatformEntryData_ *TkMenuPlatformEntryData;
/*
- * Legal values for the "compound" field of TkMenuEntry and TkMenuButton records.
+ * Legal values for the "compound" field of TkMenuEntry and TkMenuButton
+ * records.
*/
enum compound {
COMPOUND_BOTTOM, COMPOUND_CENTER, COMPOUND_LEFT, COMPOUND_NONE,
- COMPOUND_RIGHT, COMPOUND_TOP
+ COMPOUND_RIGHT, COMPOUND_TOP
};
/*
- * One of the following data structures is kept for each entry of each
- * menu managed by this file:
+ * One of the following data structures is kept for each entry of each menu
+ * managed by this file:
*/
typedef struct TkMenuEntry {
- int type; /* Type of menu entry; see below for
- * valid types. */
- struct TkMenu *menuPtr; /* Menu with which this entry is associated. */
+ int type; /* Type of menu entry; see below for valid
+ * types. */
+ struct TkMenu *menuPtr; /* Menu with which this entry is
+ * associated. */
Tk_OptionTable optionTable; /* Option table for this menu entry. */
- Tcl_Obj *labelPtr; /* Main text label displayed in entry (NULL
- * if no label). */
+ Tcl_Obj *labelPtr; /* Main text label displayed in entry (NULL if
+ * no label). */
int labelLength; /* Number of non-NULL characters in label. */
int state; /* State of button for display purposes:
* normal, active, or disabled. */
@@ -68,19 +71,18 @@ typedef struct TkMenuEntry {
Tcl_Obj *underlinePtr; /* Index of character to underline. */
Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or None.
* If not None then label is ignored. */
- Tcl_Obj *imagePtr; /* Name of image to display, or
- * NULL. If non-NULL, bitmap, text, and
- * textVarName are ignored. */
+ Tcl_Obj *imagePtr; /* Name of image to display, or NULL. If not
+ * NULL, bitmap, text, and textVarName are
+ * ignored. */
Tk_Image image; /* Image to display in menu entry, or NULL if
* none. */
- Tcl_Obj *selectImagePtr; /* Name of image to display when selected, or
+ Tcl_Obj *selectImagePtr; /* Name of image to display when selected, or
* NULL. */
- Tk_Image selectImage; /* Image to display in entry when selected,
- * or NULL if none. Ignored if image is
- * NULL. */
- Tcl_Obj *accelPtr; /* Accelerator string displayed at right
- * of menu entry. NULL means no such
- * accelerator. Malloc'ed. */
+ Tk_Image selectImage; /* Image to display in entry when selected, or
+ * NULL if none. Ignored if image is NULL. */
+ Tcl_Obj *accelPtr; /* Accelerator string displayed at right of
+ * menu entry. NULL means no such accelerator.
+ * Malloc'ed. */
int accelLength; /* Number of non-NULL characters in
* accelerator. */
int indicatorOn; /* True means draw indicator, false means
@@ -91,42 +93,43 @@ typedef struct TkMenuEntry {
*/
Tcl_Obj *borderPtr; /* Structure used to draw background for
- * entry. NULL means use overall border
- * for menu. */
- Tcl_Obj *fgPtr; /* Foreground color to use for entry. NULL
+ * entry. NULL means use overall border for
+ * menu. */
+ Tcl_Obj *fgPtr; /* Foreground color to use for entry. NULL
* means use foreground color from menu. */
Tcl_Obj *activeBorderPtr; /* Used to draw background and border when
- * element is active. NULL means use
+ * element is active. NULL means use
* activeBorder from menu. */
Tcl_Obj *activeFgPtr; /* Foreground color to use when entry is
- * active. NULL means use active foreground
+ * active. NULL means use active foreground
* from menu. */
Tcl_Obj *indicatorFgPtr; /* Color for indicators in radio and check
- * button entries. NULL means use indicatorFg
+ * button entries. NULL means use indicatorFg
* GC from menu. */
- Tcl_Obj *fontPtr; /* Text font for menu entries. NULL means
- * use overall font for menu. */
- int columnBreak; /* If this is 0, this item appears below
- * the item in front of it. If this is
- * 1, this item starts a new column. This
- * field is always 0 for tearoff and separator
+ Tcl_Obj *fontPtr; /* Text font for menu entries. NULL means use
+ * overall font for menu. */
+ int columnBreak; /* If this is 0, this item appears below the
+ * item in front of it. If this is 1, this
+ * item starts a new column. This field is
+ * always 0 for tearoff and separator
* entries. */
int hideMargin; /* If this is 0, then the item has enough
* margin to accomodate a standard check mark
* and a default right margin. If this is 1,
- * then the item has no such margins. and
+ * then the item has no such margins, and
* checkbuttons and radiobuttons with this set
- * will have a rectangle drawn in the indicator
- * around the item if the item is checked. This
- * is useful for palette menus. This field is
- * ignored for separators and tearoffs. */
+ * will have a rectangle drawn in the
+ * indicator around the item if the item is
+ * checked. This is useful for palette menus.
+ * This field is ignored for separators and
+ * tearoffs. */
int indicatorSpace; /* The width of the indicator space for this
* entry. */
int labelWidth; /* Number of pixels to allow for displaying
* labels in menu entries. */
- int compound; /* Value of -compound option; specifies whether
- * the entry should show both an image and
- * text, and, if so, how. */
+ int compound; /* Value of -compound option; specifies
+ * whether the entry should show both an image
+ * and text, and, if so, how. */
/*
* Information used to implement this entry's action:
@@ -143,19 +146,19 @@ typedef struct TkMenuEntry {
Tcl_Obj *offValuePtr; /* Value to store in variable when not
* selected (only for check buttons).
* Malloc'ed. */
-
+
/*
* Information used for drawing this menu entry.
*/
-
+
int width; /* Number of pixels occupied by entry in
- * horizontal dimension. Not used except
- * in menubars. The width of norma menus
- * is dependent on the rest of the menu. */
+ * horizontal dimension. Not used except in
+ * menubars. The width of norma menus is
+ * dependent on the rest of the menu. */
int x; /* X-coordinate of leftmost pixel in entry */
int height; /* Number of pixels occupied by entry in
- * vertical dimension, including raised
- * border drawn around entry when active. */
+ * vertical dimension, including raised border
+ * drawn around entry when active. */
int y; /* Y-coordinate of topmost pixel in entry. */
GC textGC; /* GC for drawing text in entry. NULL means
* use overall textGC for menu. */
@@ -163,51 +166,49 @@ typedef struct TkMenuEntry {
* NULL means use overall activeGC for
* menu. */
GC disabledGC; /* Used to produce disabled effect for entry.
- * NULL means use overall disabledGC from
- * menu structure. See comments for
- * disabledFg in menu structure for more
- * information. */
- GC indicatorGC; /* For drawing indicators. None means use
- * GC from menu. */
+ * NULL means use overall disabledGC from menu
+ * structure. See comments for disabledFg in
+ * menu structure for more information. */
+ GC indicatorGC; /* For drawing indicators. None means use GC
+ * from menu. */
/*
* Miscellaneous fields.
*/
-
- int entryFlags; /* Various flags. See below for
- definitions. */
- int index; /* Need to know which index we are. This
- * is zero-based. This is the top-left entry
- * of the menu. */
-
+
+ int entryFlags; /* Various flags. See below for
+ * definitions. */
+ int index; /* Need to know which index we are. This is
+ * zero-based. This is the top-left entry of
+ * the menu. */
+
/*
* Bookeeping for master menus and cascade menus.
*/
-
+
struct TkMenuReferences *childMenuRefPtr;
- /* A pointer to the hash table entry for
- * the child menu. Stored here when the menu
- * entry is configured so that a hash lookup
- * is not necessary later.*/
+ /* A pointer to the hash table entry for the
+ * child menu. Stored here when the menu entry
+ * is configured so that a hash lookup is not
+ * necessary later.*/
struct TkMenuEntry *nextCascadePtr;
/* The next cascade entry that is a parent of
- * this entry's child cascade menu. NULL
- * end of list, this is not a cascade entry,
- * or the menu that this entry point to
- * does not yet exist. */
+ * this entry's child cascade menu. NULL end
+ * of list, this is not a cascade entry, or
+ * the menu that this entry point to does not
+ * yet exist. */
TkMenuPlatformEntryData platformEntryData;
/* The data for the specific type of menu.
- * Depends on platform and menu type what
- * kind of options are in this structure.
- */
+ * Depends on platform and menu type what kind
+ * of options are in this structure. */
} TkMenuEntry;
/*
* Flag values defined for menu entries:
*
- * ENTRY_SELECTED: Non-zero means this is a radio or check
- * button and that it should be drawn in
- * the "selected" state.
+ * ENTRY_SELECTED: Non-zero means this is a radio or check button
+ * and that it should be drawn in the "selected"
+ * state.
* ENTRY_NEEDS_REDISPLAY: Non-zero means the entry should be redisplayed.
* ENTRY_LAST_COLUMN: Used by the drawing code. If the entry is in
* the last column, the space to its right needs
@@ -247,37 +248,36 @@ EXTERN char *tkMenuStateStrings[];
#define ENTRY_DISABLED 2
/*
- * A data structure of the following type is kept for each
- * menu widget:
+ * A data structure of the following type is kept for each menu widget:
*/
typedef struct TkMenu {
- Tk_Window tkwin; /* Window that embodies the pane. NULL
- * means that the window has been destroyed
- * but the data structures haven't yet been
- * cleaned up.*/
- Display *display; /* Display containing widget. Needed, among
+ Tk_Window tkwin; /* Window that embodies the pane. NULL means
+ * that the window has been destroyed but the
+ * data structures haven't yet been cleaned
+ * up. */
+ Display *display; /* Display containing widget. Needed, among
* other things, so that resources can be
* freed up even after tkwin has gone away. */
Tcl_Interp *interp; /* Interpreter associated with menu. */
Tcl_Command widgetCmd; /* Token for menu's widget command. */
- TkMenuEntry **entries; /* Array of pointers to all the entries
- * in the menu. NULL means no entries. */
+ TkMenuEntry **entries; /* Array of pointers to all the entries in the
+ * menu. NULL means no entries. */
int numEntries; /* Number of elements in entries. */
- int active; /* Index of active entry. -1 means
- * nothing active. */
- int menuType; /* MASTER_MENU, TEAROFF_MENU, or MENUBAR.
- * See below for definitions. */
- Tcl_Obj *menuTypePtr; /* Used to control whether created tkwin
- * is a toplevel or not. "normal", "menubar",
- * or "toplevel" */
+ int active; /* Index of active entry. -1 means nothing
+ * active. */
+ int menuType; /* MASTER_MENU, TEAROFF_MENU, or MENUBAR. See
+ * below for definitions. */
+ Tcl_Obj *menuTypePtr; /* Used to control whether created tkwin is a
+ * toplevel or not. "normal", "menubar", or
+ * "toplevel" */
/*
* Information used when displaying widget:
*/
- Tcl_Obj *borderPtr; /* Structure used to draw 3-D
- * border and background for menu. */
+ Tcl_Obj *borderPtr; /* Structure used to draw 3-D border and
+ * background for menu. */
Tcl_Obj *borderWidthPtr; /* Width of border around whole menu. */
Tcl_Obj *activeBorderPtr; /* Used to draw background and border for
* active element (if any). */
@@ -286,18 +286,17 @@ typedef struct TkMenu {
Tcl_Obj *reliefPtr; /* 3-d effect: TK_RELIEF_RAISED, etc. */
Tcl_Obj *fontPtr; /* Text font for menu entries. */
Tcl_Obj *fgPtr; /* Foreground color for entries. */
- Tcl_Obj *disabledFgPtr; /* Foreground color when disabled. NULL
- * means use normalFg with a 50% stipple
- * instead. */
+ Tcl_Obj *disabledFgPtr; /* Foreground color when disabled. NULL means
+ * use normalFg with a 50% stipple instead. */
Tcl_Obj *activeFgPtr; /* Foreground color for active entry. */
Tcl_Obj *indicatorFgPtr; /* Color for indicators in radio and check
* button entries. */
- Pixmap gray; /* Bitmap for drawing disabled entries in
- * a stippled fashion. None means not
- * allocated yet. */
- GC textGC; /* GC for drawing text and other features
- * of menu entries. */
- GC disabledGC; /* Used to produce disabled effect. If
+ Pixmap gray; /* Bitmap for drawing disabled entries in a
+ * stippled fashion. None means not allocated
+ * yet. */
+ GC textGC; /* GC for drawing text and other features of
+ * menu entries. */
+ GC disabledGC; /* Used to produce disabled effect. If
* disabledFg isn't NULL, this GC is used to
* draw text and icons for disabled entries.
* Otherwise text and icons are drawn with
@@ -305,44 +304,43 @@ typedef struct TkMenu {
* background across them. */
GC activeGC; /* GC for drawing active entry. */
GC indicatorGC; /* For drawing indicators. */
- GC disabledImageGC; /* Used for drawing disabled images. They
- * have to be stippled. This is created
- * when the image is about to be drawn the
- * first time. */
+ GC disabledImageGC; /* Used for drawing disabled images. They have
+ * to be stippled. This is created when the
+ * image is about to be drawn the first
+ * time. */
/*
* Information about geometry of menu.
*/
-
+
int totalWidth; /* Width of entire menu */
int totalHeight; /* Height of entire menu */
-
+
/*
* Miscellaneous information:
*/
int tearoff; /* 1 means this menu can be torn off. On some
- * platforms, the user can drag an outline
- * of the menu by just dragging outside of
- * the menu, and the tearoff is created where
- * the mouse is released. On others, an
- * indicator (such as a dashed stripe) is
- * drawn, and when the menu is selected, the
- * tearoff is created. */
+ * platforms, the user can drag an outline of
+ * the menu by just dragging outside of the
+ * menu, and the tearoff is created where the
+ * mouse is released. On others, an indicator
+ * (such as a dashed stripe) is drawn, and
+ * when the menu is selected, the tearoff is
+ * created. */
Tcl_Obj *titlePtr; /* The title to use when this menu is torn
- * off. If this is NULL, a default scheme
- * will be used to generate a title for
- * tearoff. */
- Tcl_Obj *tearoffCommandPtr; /* If non-NULL, points to a command to
- * run whenever the menu is torn-off. */
- Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in
- * the C code, but used by keyboard traversal
+ * off. If this is NULL, a default scheme will
+ * be used to generate a title for tearoff. */
+ Tcl_Obj *tearoffCommandPtr; /* If non-NULL, points to a command to run
+ * whenever the menu is torn-off. */
+ Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the
+ * C code, but used by keyboard traversal
* scripts. Malloc'ed, but may be NULL. */
Tcl_Obj *cursorPtr; /* Current cursor for window, or None. */
Tcl_Obj *postCommandPtr; /* Used to detect cycles in cascade hierarchy
- * trees when preprocessing postcommands
- * on some platforms. See PostMenu for
- * more details. */
+ * trees when preprocessing postcommands on
+ * some platforms. See PostMenu for more
+ * details. */
int postCommandGeneration; /* Need to do pre-invocation post command
* traversal */
int menuFlags; /* Flags for use by X; see below for
@@ -350,7 +348,7 @@ typedef struct TkMenu {
TkMenuEntry *postedCascade; /* Points to menu entry for cascaded submenu
* that is currently posted or NULL if no
* submenu posted. */
- struct TkMenu *nextInstancePtr;
+ struct TkMenu *nextInstancePtr;
/* The next instance of this menu in the
* chain. */
struct TkMenu *masterMenuPtr;
@@ -358,29 +356,26 @@ typedef struct TkMenu {
* clone chain. Points back to this structure
* if this menu is a master menu. */
struct TkMenuOptionTables *optionTablesPtr;
- /* A pointer to the collection of option tables
- * that work with menus and menu entries. */
+ /* A pointer to the collection of option
+ * tables that work with menus and menu
+ * entries. */
Tk_Window parentTopLevelPtr;/* If this menu is a menubar, this is the
- * toplevel that owns the menu. Only applicable
- * for menubar clones.
- */
- struct TkMenuReferences *menuRefPtr;
+ * toplevel that owns the menu. Only
+ * applicable for menubar clones. */
+ struct TkMenuReferences *menuRefPtr;
/* Each menu is hashed into a table with the
- * name of the menu's window as the key.
- * The information in this hash table includes
- * a pointer to the menu (so that cascades
- * can find this menu), a pointer to the
- * list of toplevel widgets that have this
- * menu as its menubar, and a list of menu
- * entries that have this menu specified
- * as a cascade. */
+ * name of the menu's window as the key. The
+ * information in this hash table includes a
+ * pointer to the menu (so that cascades can
+ * find this menu), a pointer to the list of
+ * toplevel widgets that have this menu as its
+ * menubar, and a list of menu entries that
+ * have this menu specified as a cascade. */
TkMenuPlatformData platformData;
/* The data for the specific type of menu.
- * Depends on platform and menu type what
- * kind of options are in this structure.
- */
- Tk_OptionSpec *extensionPtr;
- /* Needed by the configuration package for
+ * Depends on platform and menu type what kind
+ * of options are in this structure. */
+ Tk_OptionSpec *extensionPtr;/* Needed by the configuration package for
* this widget to be extended. */
Tk_SavedOptions *errorStructPtr;
/* We actually have to allocate these because
@@ -390,8 +385,8 @@ typedef struct TkMenu {
/*
* When the toplevel configure -menu command is executed, the menu may not
- * exist yet. We need to keep a linked list of windows that reference
- * a particular menu.
+ * exist yet. We need to keep a linked list of windows that reference a
+ * particular menu.
*/
typedef struct TkMenuTopLevelList {
@@ -402,61 +397,60 @@ typedef struct TkMenuTopLevelList {
} TkMenuTopLevelList;
/*
- * The following structure is used to keep track of things which
- * reference a menu. It is created when:
+ * The following structure is used to keep track of things which reference a
+ * menu. It is created when:
* - a menu is created.
* - a cascade entry is added to a menu with a non-null name
- * - the "-menu" configuration option is used on a toplevel widget
- * with a non-null parameter.
+ * - the "-menu" configuration option is used on a toplevel widget with a
+ * non-null parameter.
*
- * One of these three fields must be non-NULL, but any of the fields may
- * be NULL. This structure makes it easy to determine whether or not
- * anything like recalculating platform data or geometry is necessary
- * when one of the three actions above is performed.
+ * One of these three fields must be non-NULL, but any of the fields may be
+ * NULL. This structure makes it easy to determine whether or not anything
+ * like recalculating platform data or geometry is necessary when one of the
+ * three actions above is performed.
*/
typedef struct TkMenuReferences {
- struct TkMenu *menuPtr; /* The menu data structure. This is NULL
- * if the menu does not exist. */
+ struct TkMenu *menuPtr; /* The menu data structure. This is NULL if
+ * the menu does not exist. */
TkMenuTopLevelList *topLevelListPtr;
- /* First in the list of all toplevels that
- * have this menu as its menubar. NULL if no
+ /* First in the list of all toplevels that
+ * have this menu as its menubar. NULL if no
* toplevel widgets have this menu as its
* menubar. */
- TkMenuEntry *parentEntryPtr;/* First in the list of all cascade menu
+ TkMenuEntry *parentEntryPtr;/* First in the list of all cascade menu
* entries that have this menu as their child.
* NULL means no cascade entries. */
Tcl_HashEntry *hashEntryPtr;/* This is needed because the pathname of the
* window (which is what we hash on) may not
- * be around when we are deleting.
- */
+ * be around when we are deleting. */
} TkMenuReferences;
/*
- * This structure contains all of the option tables that are needed
- * by menus.
+ * This structure contains all of the option tables that are needed by menus.
*/
typedef struct TkMenuOptionTables {
- Tk_OptionTable menuOptionTable; /* The option table for menus. */
- Tk_OptionTable entryOptionTables[6];/* The tables for menu entries. */
+ Tk_OptionTable menuOptionTable;
+ /* The option table for menus. */
+ Tk_OptionTable entryOptionTables[6];
+ /* The tables for menu entries. */
} TkMenuOptionTables;
/*
* Flag bits for menus:
*
- * REDRAW_PENDING: Non-zero means a DoWhenIdle handler
- * has already been queued to redraw
- * this window.
+ * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has
+ * already been queued to redraw this window.
* RESIZE_PENDING: Non-zero means a call to ComputeMenuGeometry
* has already been scheduled.
- * MENU_DELETION_PENDING Non-zero means that we are currently destroying
- * this menu's internal structures. This is useful
- * when we are in the middle of cleaning
- * this master menu's chain of menus up when
- * TkDestroyMenu was called again on this
+ * MENU_DELETION_PENDING Non-zero means that we are currently
+ * destroying this menu's internal structures.
+ * This is useful when we are in the middle of
+ * cleaning this master menu's chain of menus up
+ * when TkDestroyMenu was called again on this
* menu (via a destroy binding or somesuch).
- * MENU_WIN_DESTRUCTION_PENDING Non-zero means we are in the middle of
+ * MENU_WIN_DESTRUCTION_PENDING Non-zero means we are in the middle of
* destroying this menu's Tk_Window.
* MENU_PLATFORM_FLAG1... Reserved for use by the platform-specific menu
* code.
@@ -471,14 +465,14 @@ typedef struct TkMenuOptionTables {
#define MENU_PLATFORM_FLAG3 (1 << 28)
/*
- * Each menu created by the user is a MASTER_MENU. When a menu is torn off,
- * a TEAROFF_MENU instance is created. When a menu is assigned to a toplevel
- * as a menu bar, a MENUBAR instance is created. All instances have the same
+ * Each menu created by the user is a MASTER_MENU. When a menu is torn off, a
+ * TEAROFF_MENU instance is created. When a menu is assigned to a toplevel as
+ * a menu bar, a MENUBAR instance is created. All instances have the same
* configuration information. If the master instance is deleted, all instances
* are deleted. If one of the other instances is deleted, only that instance
* is deleted.
*/
-
+
#define UNKNOWN_TYPE -1
#define MASTER_MENU 0
#define TEAROFF_MENU 1
@@ -493,93 +487,74 @@ typedef struct TkMenuOptionTables {
#define DECORATION_BORDER_WIDTH 2
/*
- * Menu-related procedures that are shared among Tk modules but not exported
- * to the outside world:
+ * Menu-related functions that are shared among Tk modules but not exported to
+ * the outside world:
*/
-EXTERN int TkActivateMenuEntry _ANSI_ARGS_((TkMenu *menuPtr,
- int index));
-EXTERN void TkBindMenu _ANSI_ARGS_((
- Tk_Window tkwin, TkMenu *menuPtr));
-EXTERN TkMenuReferences *
- TkCreateMenuReferences _ANSI_ARGS_((Tcl_Interp *interp,
- char *name));
-EXTERN void TkDestroyMenu _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN void TkEventuallyRecomputeMenu _ANSI_ARGS_((
- TkMenu *menuPtr));
-EXTERN void TkEventuallyRedrawMenu _ANSI_ARGS_((
- TkMenu *menuPtr, TkMenuEntry *mePtr));
-EXTERN TkMenuReferences *
- TkFindMenuReferences _ANSI_ARGS_((Tcl_Interp *interp,
- char *name));
-EXTERN TkMenuReferences *
- TkFindMenuReferencesObj _ANSI_ARGS_((
- Tcl_Interp *interp, Tcl_Obj *namePtr));
-EXTERN int TkFreeMenuReferences _ANSI_ARGS_((
- TkMenuReferences *menuRefPtr));
-EXTERN Tcl_HashTable * TkGetMenuHashTable _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN int TkGetMenuIndex _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, Tcl_Obj *objPtr, int lastOK,
- int *indexPtr));
-EXTERN void TkMenuInitializeDrawingFields _ANSI_ARGS_((
- TkMenu *menuPtr));
-EXTERN void TkMenuInitializeEntryDrawingFields _ANSI_ARGS_((
- TkMenuEntry *mePtr));
-EXTERN int TkInvokeMenu _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, int index));
-EXTERN void TkMenuConfigureDrawOptions _ANSI_ARGS_((
- TkMenu *menuPtr));
-EXTERN int TkMenuConfigureEntryDrawOptions _ANSI_ARGS_((
- TkMenuEntry *mePtr, int index));
-EXTERN void TkMenuFreeDrawOptions _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN void TkMenuEntryFreeDrawOptions _ANSI_ARGS_((
- TkMenuEntry *mePtr));
-EXTERN void TkMenuEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-EXTERN void TkMenuImageProc _ANSI_ARGS_((
- ClientData clientData, int x, int y, int width,
- int height, int imgWidth, int imgHeight));
-EXTERN void TkMenuInit _ANSI_ARGS_((void));
-EXTERN void TkMenuSelectImageProc _ANSI_ARGS_
- ((ClientData clientData, int x, int y,
+EXTERN int TkActivateMenuEntry(TkMenu *menuPtr, int index);
+EXTERN void TkBindMenu(Tk_Window tkwin, TkMenu *menuPtr);
+EXTERN TkMenuReferences*TkCreateMenuReferences(Tcl_Interp *interp,
+ char *name);
+EXTERN void TkDestroyMenu(TkMenu *menuPtr);
+EXTERN void TkEventuallyRecomputeMenu(TkMenu *menuPtr);
+EXTERN void TkEventuallyRedrawMenu(TkMenu *menuPtr,
+ TkMenuEntry *mePtr);
+EXTERN TkMenuReferences*TkFindMenuReferences(Tcl_Interp *interp, char *name);
+EXTERN TkMenuReferences*TkFindMenuReferencesObj(Tcl_Interp *interp,
+ Tcl_Obj *namePtr);
+EXTERN int TkFreeMenuReferences(TkMenuReferences *menuRefPtr);
+EXTERN Tcl_HashTable * TkGetMenuHashTable(Tcl_Interp *interp);
+EXTERN int TkGetMenuIndex(Tcl_Interp *interp, TkMenu *menuPtr,
+ Tcl_Obj *objPtr, int lastOK, int *indexPtr);
+EXTERN void TkMenuInitializeDrawingFields(TkMenu *menuPtr);
+EXTERN void TkMenuInitializeEntryDrawingFields(TkMenuEntry *mePtr);
+EXTERN int TkInvokeMenu(Tcl_Interp *interp, TkMenu *menuPtr,
+ int index);
+EXTERN void TkMenuConfigureDrawOptions(TkMenu *menuPtr);
+EXTERN int TkMenuConfigureEntryDrawOptions(
+ TkMenuEntry *mePtr, int index);
+EXTERN void TkMenuFreeDrawOptions(TkMenu *menuPtr);
+EXTERN void TkMenuEntryFreeDrawOptions(TkMenuEntry *mePtr);
+EXTERN void TkMenuEventProc(ClientData clientData,
+ XEvent *eventPtr);
+EXTERN void TkMenuImageProc(ClientData clientData, int x, int y,
int width, int height, int imgWidth,
- int imgHeight));
-EXTERN Tcl_Obj * TkNewMenuName _ANSI_ARGS_((Tcl_Interp *interp,
- Tcl_Obj *parentNamePtr, TkMenu *menuPtr));
-EXTERN int TkPostCommand _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN int TkPostSubmenu _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, TkMenuEntry *mePtr));
-EXTERN int TkPostTearoffMenu _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, int x, int y));
-EXTERN int TkPreprocessMenu _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN void TkRecomputeMenu _ANSI_ARGS_((TkMenu *menuPtr));
+ int imgHeight);
+EXTERN void TkMenuInit(void);
+EXTERN void TkMenuSelectImageProc(ClientData clientData, int x,
+ int y, int width, int height, int imgWidth,
+ int imgHeight);
+EXTERN Tcl_Obj * TkNewMenuName(Tcl_Interp *interp,
+ Tcl_Obj *parentNamePtr, TkMenu *menuPtr);
+EXTERN int TkPostCommand(TkMenu *menuPtr);
+EXTERN int TkPostSubmenu(Tcl_Interp *interp, TkMenu *menuPtr,
+ TkMenuEntry *mePtr);
+EXTERN int TkPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr,
+ int x, int y);
+EXTERN int TkPreprocessMenu(TkMenu *menuPtr);
+EXTERN void TkRecomputeMenu(TkMenu *menuPtr);
/*
- * These routines are the platform-dependent routines called by the
- * common code.
+ * These routines are the platform-dependent routines called by the common
+ * code.
*/
-EXTERN void TkpComputeMenubarGeometry _ANSI_ARGS_((
- TkMenu *menuPtr));
-EXTERN void TkpComputeStandardMenuGeometry _ANSI_ARGS_
- ((TkMenu *menuPtr));
-EXTERN int TkpConfigureMenuEntry
- _ANSI_ARGS_((TkMenuEntry *mePtr));
-EXTERN void TkpDestroyMenu _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN void TkpDestroyMenuEntry
- _ANSI_ARGS_((TkMenuEntry *mEntryPtr));
-EXTERN void TkpDrawMenuEntry _ANSI_ARGS_((TkMenuEntry *mePtr,
- Drawable d, Tk_Font tkfont,
+EXTERN void TkpComputeMenubarGeometry(TkMenu *menuPtr);
+EXTERN void TkpComputeStandardMenuGeometry(TkMenu *menuPtr);
+EXTERN int TkpConfigureMenuEntry(TkMenuEntry *mePtr);
+EXTERN void TkpDestroyMenu(TkMenu *menuPtr);
+EXTERN void TkpDestroyMenuEntry(TkMenuEntry *mEntryPtr);
+EXTERN void TkpDrawMenuEntry(TkMenuEntry *mePtr,
+ Drawable d, Tk_Font tkfont,
CONST Tk_FontMetrics *menuMetricsPtr, int x,
int y, int width, int height, int strictMotif,
- int drawArrow));
-EXTERN void TkpMenuInit _ANSI_ARGS_((void));
-EXTERN int TkpMenuNewEntry _ANSI_ARGS_((TkMenuEntry *mePtr));
-EXTERN int TkpNewMenu _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN int TkpPostMenu _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, int x, int y));
-EXTERN void TkpSetWindowMenuBar _ANSI_ARGS_((Tk_Window tkwin,
- TkMenu *menuPtr));
+ int drawArrow);
+EXTERN void TkpMenuInit(void);
+EXTERN int TkpMenuNewEntry(TkMenuEntry *mePtr);
+EXTERN int TkpNewMenu(TkMenu *menuPtr);
+EXTERN int TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr,
+ int x, int y);
+EXTERN void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr);
# undef TCL_STORAGE_CLASS
# define TCL_STORAGE_CLASS DLLIMPORT
diff --git a/generic/tkMessage.c b/generic/tkMessage.c
index b32ecfc..eb4974d 100644
--- a/generic/tkMessage.c
+++ b/generic/tkMessage.c
@@ -1,18 +1,18 @@
-/*
+/*
* tkMessage.c --
*
- * This module implements a message widgets for the Tk
- * toolkit. A message widget displays a multi-line string
- * in a window according to a particular aspect ratio.
+ * This module implements a message widgets for the Tk toolkit. A message
+ * widget displays a multi-line string in a window according to a
+ * particular aspect ratio.
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
* Copyright (c) 1998-2000 by Ajuba Solutions.
*
- * 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: tkMessage.c,v 1.14 2002/08/05 04:30:40 dgp Exp $
+ * RCS: @(#) $Id: tkMessage.c,v 1.15 2005/11/14 22:44:11 dkf Exp $
*/
#include "tkPort.h"
@@ -20,18 +20,18 @@
#include "tkInt.h"
/*
- * A data structure of the following type is kept for each message
- * widget managed by this file:
+ * A data structure of the following type is kept for each message widget
+ * managed by this file:
*/
typedef struct {
- Tk_Window tkwin; /* Window that embodies the message. NULL
+ Tk_Window tkwin; /* Window that embodies the message. NULL
* means that the window has been destroyed
* but the data structures haven't yet been
* cleaned up.*/
Tk_OptionTable optionTable; /* Table that defines options available for
* this widget. */
- Display *display; /* Display containing widget. Used, among
+ Display *display; /* Display containing widget. Used, among
* other things, so that resources can be
* freed even after tkwin has gone away. */
Tcl_Interp *interp; /* Interpreter associated with message. */
@@ -48,8 +48,8 @@ typedef struct {
* If non-NULL, message displays the contents
* of this variable. */
Tk_3DBorder border; /* Structure used to draw 3-D border and
- * background. NULL means a border hasn't
- * been created yet. */
+ * background. NULL means a border hasn't been
+ * created yet. */
int borderWidth; /* Width of border. */
int relief; /* 3-D effect: TK_RELIEF_RAISED, etc. */
int highlightWidth; /* Width in pixels of highlight to draw
@@ -63,7 +63,7 @@ typedef struct {
XColor *fgColorPtr; /* Foreground color in normal mode. */
Tcl_Obj *padXPtr, *padYPtr; /* Tcl_Obj rep's of padX, padY values. */
int padX, padY; /* User-requested extra space around text. */
- int width; /* User-requested width, in pixels. 0 means
+ int width; /* User-requested width, in pixels. 0 means
* compute width using aspect ratio below. */
int aspect; /* Desired aspect ratio for window
* (100*width/height). */
@@ -84,10 +84,10 @@ typedef struct {
*/
Tk_Cursor cursor; /* Current cursor for window, or None. */
- char *takeFocus; /* Value of -takefocus option; not used in
- * the C code, but used by keyboard traversal
- * scripts. Malloc'ed, but may be NULL. */
- int flags; /* Various flags; see below for
+ char *takeFocus; /* Value of -takefocus option; not used in the
+ * C code, but used by keyboard traversal
+ * scripts. Malloc'ed, but may be NULL. */
+ int flags; /* Various flags; see below for
* definitions. */
} Message;
@@ -118,9 +118,9 @@ static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
DEF_MESSAGE_BG_COLOR, -1, Tk_Offset(Message, border), 0,
(ClientData) DEF_MESSAGE_BG_MONO, 0},
- {TK_OPTION_SYNONYM, "-bd", (char *) NULL, (char *) NULL, (char *) NULL,
+ {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL,
0, -1, 0, (ClientData) "-borderwidth", 0},
- {TK_OPTION_SYNONYM, "-bg", (char *) NULL, (char *) NULL, (char *) NULL,
+ {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL,
0, -1, 0, (ClientData) "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
DEF_MESSAGE_BORDER_WIDTH, -1,
@@ -128,7 +128,7 @@ static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
DEF_MESSAGE_CURSOR, -1, Tk_Offset(Message, cursor),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_SYNONYM, "-fg", (char *) NULL, (char *) NULL, (char *) NULL,
+ {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL,
0, -1, 0, (ClientData) "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
DEF_MESSAGE_FONT, -1, Tk_Offset(Message, tkfont), 0, 0, 0},
@@ -163,35 +163,31 @@ static Tk_OptionSpec optionSpecs[] = {
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
DEF_MESSAGE_WIDTH, -1, Tk_Offset(Message, width), 0, 0 ,0},
- {TK_OPTION_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0}
};
/*
- * Forward declarations for procedures defined later in this file:
+ * Forward declarations for functions defined later in this file:
*/
-static void MessageCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-static void MessageEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static char * MessageTextVarProc _ANSI_ARGS_((ClientData clientData,
+static void MessageCmdDeletedProc(ClientData clientData);
+static void MessageEventProc(ClientData clientData,
+ XEvent *eventPtr);
+static char * MessageTextVarProc(ClientData clientData,
Tcl_Interp *interp, CONST char *name1,
- CONST char *name2, int flags));
-static int MessageWidgetObjCmd _ANSI_ARGS_((ClientData clientData,
+ CONST char *name2, int flags);
+static int MessageWidgetObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-static void MessageWorldChanged _ANSI_ARGS_((
- ClientData instanceData));
-static void ComputeMessageGeometry _ANSI_ARGS_((Message *msgPtr));
-static int ConfigureMessage _ANSI_ARGS_((Tcl_Interp *interp,
- Message *msgPtr, int objc, Tcl_Obj *CONST objv[],
- int flags));
-static void DestroyMessage _ANSI_ARGS_((char *memPtr));
-static void DisplayMessage _ANSI_ARGS_((ClientData clientData));
+ Tcl_Obj *CONST objv[]);
+static void MessageWorldChanged(ClientData instanceData);
+static void ComputeMessageGeometry(Message *msgPtr);
+static int ConfigureMessage(Tcl_Interp *interp, Message *msgPtr,
+ int objc, Tcl_Obj *CONST objv[], int flags);
+static void DestroyMessage(char *memPtr);
+static void DisplayMessage(ClientData clientData);
/*
- * The structure below defines message class behavior by means of procedures
+ * The structure below defines message class behavior by means of functions
* that can be invoked from generic window code.
*/
@@ -199,16 +195,14 @@ static Tk_ClassProcs messageClass = {
sizeof(Tk_ClassProcs), /* size */
MessageWorldChanged, /* worldChangedProc */
};
-
/*
*--------------------------------------------------------------
*
* Tk_MessageObjCmd --
*
- * This procedure is invoked to process the "message" Tcl
- * command. See the user documentation for details on what
- * it does.
+ * This function is invoked to process the "message" Tcl command. See the
+ * user documentation for details on what it does.
*
* Results:
* A standard Tcl result.
@@ -220,11 +214,11 @@ static Tk_ClassProcs messageClass = {
*/
int
-Tk_MessageObjCmd(clientData, interp, objc, objv)
- ClientData clientData; /* NULL. */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument strings. */
+Tk_MessageObjCmd(
+ ClientData clientData, /* NULL. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST objv[]) /* Argument strings. */
{
register Message *msgPtr;
Tk_OptionTable optionTable;
@@ -236,14 +230,14 @@ Tk_MessageObjCmd(clientData, interp, objc, objv)
}
tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp),
- Tcl_GetString(objv[1]), (char *) NULL);
+ Tcl_GetString(objv[1]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
}
/*
- * Create the option table for this widget class. If it has already
- * been created, the cached pointer will be returned.
+ * Create the option table for this widget class. If it has already been
+ * created, the cached pointer will be returned.
*/
optionTable = Tk_CreateOptionTable(interp, optionSpecs);
@@ -254,19 +248,20 @@ Tk_MessageObjCmd(clientData, interp, objc, objv)
/*
* Set values for those fields that don't take a 0 or NULL value.
*/
- msgPtr->tkwin = tkwin;
- msgPtr->display = Tk_Display(tkwin);
- msgPtr->interp = interp;
- msgPtr->widgetCmd = Tcl_CreateObjCommand(interp,
+
+ msgPtr->tkwin = tkwin;
+ msgPtr->display = Tk_Display(tkwin);
+ msgPtr->interp = interp;
+ msgPtr->widgetCmd = Tcl_CreateObjCommand(interp,
Tk_PathName(msgPtr->tkwin), MessageWidgetObjCmd,
(ClientData) msgPtr, MessageCmdDeletedProc);
- msgPtr->optionTable = optionTable;
- msgPtr->relief = TK_RELIEF_FLAT;
- msgPtr->textGC = None;
- msgPtr->anchor = TK_ANCHOR_CENTER;
- msgPtr->aspect = 150;
- msgPtr->justify = TK_JUSTIFY_LEFT;
- msgPtr->cursor = None;
+ msgPtr->optionTable = optionTable;
+ msgPtr->relief = TK_RELIEF_FLAT;
+ msgPtr->textGC = None;
+ msgPtr->anchor = TK_ANCHOR_CENTER;
+ msgPtr->aspect = 150;
+ msgPtr->justify = TK_JUSTIFY_LEFT;
+ msgPtr->cursor = None;
Tk_SetClass(msgPtr->tkwin, "Message");
Tk_SetClassProcs(msgPtr->tkwin, &messageClass, (ClientData) msgPtr);
@@ -292,9 +287,9 @@ Tk_MessageObjCmd(clientData, interp, objc, objv)
*
* MessageWidgetObjCmd --
*
- * This procedure is invoked to process the Tcl command
- * that corresponds to a widget managed by this module.
- * See the user documentation for details on what it does.
+ * This function is invoked to process the Tcl command that corresponds
+ * to a widget managed by this module. See the user documentation for
+ * details on what it does.
*
* Results:
* A standard Tcl result.
@@ -306,19 +301,19 @@ Tk_MessageObjCmd(clientData, interp, objc, objv)
*/
static int
-MessageWidgetObjCmd(clientData, interp, objc, objv)
- ClientData clientData; /* Information about message widget. */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument strings. */
+MessageWidgetObjCmd(
+ ClientData clientData, /* Information about message widget. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *CONST objv[]) /* Argument strings. */
{
register Message *msgPtr = (Message *) clientData;
- static CONST char *optionStrings[] = { "cget", "configure", (char *) NULL };
+ static CONST char *optionStrings[] = { "cget", "configure", NULL };
enum options { MESSAGE_CGET, MESSAGE_CONFIGURE };
int index;
int result = TCL_OK;
Tcl_Obj *objPtr;
-
+
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg ...?");
return TCL_ERROR;
@@ -330,42 +325,39 @@ MessageWidgetObjCmd(clientData, interp, objc, objv)
}
Tcl_Preserve((ClientData) msgPtr);
-
+
switch ((enum options) index) {
- case MESSAGE_CGET: {
- if (objc != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "option");
- return TCL_ERROR;
- }
- objPtr = Tk_GetOptionValue(interp, (char *) msgPtr,
- msgPtr->optionTable, objv[2], msgPtr->tkwin);
+ case MESSAGE_CGET:
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "option");
+ return TCL_ERROR;
+ }
+ objPtr = Tk_GetOptionValue(interp, (char *) msgPtr,
+ msgPtr->optionTable, objv[2], msgPtr->tkwin);
+ if (objPtr == NULL) {
+ result = TCL_ERROR;
+ } else {
+ Tcl_SetObjResult(interp, objPtr);
+ result = TCL_OK;
+ }
+ break;
+ case MESSAGE_CONFIGURE:
+ if (objc <= 3) {
+ objPtr = Tk_GetOptionInfo(interp, (char *) msgPtr,
+ msgPtr->optionTable, (objc == 3) ? objv[2] : NULL,
+ msgPtr->tkwin);
if (objPtr == NULL) {
result = TCL_ERROR;
} else {
Tcl_SetObjResult(interp, objPtr);
result = TCL_OK;
}
- break;
- }
- case MESSAGE_CONFIGURE: {
- if (objc <= 3) {
- objPtr = Tk_GetOptionInfo(interp, (char *) msgPtr,
- msgPtr->optionTable,
- (objc == 3) ? objv[2] : (Tcl_Obj *) NULL,
- msgPtr->tkwin);
- if (objPtr == NULL) {
- result = TCL_ERROR;
- } else {
- Tcl_SetObjResult(interp, objPtr);
- result = TCL_OK;
- }
- } else {
- result = ConfigureMessage(interp, msgPtr, objc-2, objv+2, 0);
- }
- break;
+ } else {
+ result = ConfigureMessage(interp, msgPtr, objc-2, objv+2, 0);
}
+ break;
}
-
+
Tcl_Release((ClientData) msgPtr);
return result;
}
@@ -375,9 +367,9 @@ MessageWidgetObjCmd(clientData, interp, objc, objv)
*
* DestroyMessage --
*
- * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
- * to clean up the internal structure of a message at a safe time
- * (when no-one is using it anymore).
+ * This function is invoked by Tcl_EventuallyFree or Tcl_Release to clean
+ * up the internal structure of a message at a safe time (when no-one is
+ * using it anymore).
*
* Results:
* None.
@@ -389,8 +381,8 @@ MessageWidgetObjCmd(clientData, interp, objc, objv)
*/
static void
-DestroyMessage(memPtr)
- char *memPtr; /* Info about message widget. */
+DestroyMessage(
+ char *memPtr) /* Info about message widget. */
{
register Message *msgPtr = (Message *) memPtr;
@@ -400,11 +392,10 @@ DestroyMessage(memPtr)
if (msgPtr->flags & REDRAW_PENDING) {
Tcl_CancelIdleCall(DisplayMessage, (ClientData) msgPtr);
}
-
+
/*
- * Free up all the stuff that requires special handling, then
- * let Tk_FreeConfigOptions handle all the standard option-related
- * stuff.
+ * Free up all the stuff that requires special handling, then let
+ * Tk_FreeConfigOptions handle all the standard option-related stuff.
*/
if (msgPtr->textGC != None) {
@@ -428,30 +419,29 @@ DestroyMessage(memPtr)
*
* ConfigureMessage --
*
- * This procedure is called to process an argv/argc list, plus
- * the Tk option database, in order to configure (or
- * reconfigure) a message widget.
+ * This function is called to process an argv/argc list, plus the Tk
+ * option database, in order to configure (or reconfigure) a message
+ * widget.
*
* Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then the interp's result contains an error message.
+ * The return value is a standard Tcl result. If TCL_ERROR is returned,
+ * then the interp's result contains an error message.
*
* Side effects:
- * Configuration information, such as text string, colors, font,
- * etc. get set for msgPtr; old resources get freed, if there
- * were any.
+ * Configuration information, such as text string, colors, font, etc. get
+ * set for msgPtr; old resources get freed, if there were any.
*
*----------------------------------------------------------------------
*/
static int
-ConfigureMessage(interp, msgPtr, objc, objv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- register Message *msgPtr; /* Information about widget; may or may
- * not already have values for some fields. */
- int objc; /* Number of valid entries in argv. */
- Tcl_Obj *CONST objv[]; /* Arguments. */
- int flags; /* Flags to pass to Tk_ConfigureWidget. */
+ConfigureMessage(
+ Tcl_Interp *interp, /* Used for error reporting. */
+ register Message *msgPtr, /* Information about widget; may or may not
+ * already have values for some fields. */
+ int objc, /* Number of valid entries in argv. */
+ Tcl_Obj *CONST objv[], /* Arguments. */
+ int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
Tk_SavedOptions savedOptions;
@@ -460,22 +450,21 @@ ConfigureMessage(interp, msgPtr, objc, objv, flags)
*/
if (msgPtr->textVarName != NULL) {
- Tcl_UntraceVar(interp, msgPtr->textVarName,
+ Tcl_UntraceVar(interp, msgPtr->textVarName,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
MessageTextVarProc, (ClientData) msgPtr);
}
if (Tk_SetOptions(interp, (char *) msgPtr, msgPtr->optionTable, objc, objv,
- msgPtr->tkwin, &savedOptions, (int *)NULL) != TCL_OK) {
+ msgPtr->tkwin, &savedOptions, NULL) != TCL_OK) {
Tk_RestoreSavedOptions(&savedOptions);
return TCL_ERROR;
}
-
-
+
/*
- * If the message is to display the value of a variable, then set up
- * a trace on the variable's value, create the variable if it doesn't
- * exist, and fetch its current value.
+ * If the message is to display the value of a variable, then set up a
+ * trace on the variable's value, create the variable if it doesn't exist,
+ * and fetch its current value.
*/
if (msgPtr->textVarName != NULL) {
@@ -497,9 +486,9 @@ ConfigureMessage(interp, msgPtr, objc, objv, flags)
}
/*
- * A few other options need special processing, such as setting
- * the background from a 3-D border or handling special defaults
- * that couldn't be specified to Tk_ConfigureWidget.
+ * A few other options need special processing, such as setting the
+ * background from a 3-D border or handling special defaults that couldn't
+ * be specified to Tk_ConfigureWidget.
*/
msgPtr->numChars = Tcl_NumUtfChars(msgPtr->string, -1);
@@ -518,22 +507,22 @@ ConfigureMessage(interp, msgPtr, objc, objv, flags)
*
* MessageWorldChanged --
*
- * This procedure is called when the world has changed in some
- * way and the widget needs to recompute all its graphics contexts
- * and determine its new geometry.
+ * This function is called when the world has changed in some way and the
+ * widget needs to recompute all its graphics contexts and determine its
+ * new geometry.
*
* Results:
- * None.
+ * None.
*
* Side effects:
- * Message will be relayed out and redisplayed.
+ * Message will be relayed out and redisplayed.
*
*---------------------------------------------------------------------------
*/
-
+
static void
-MessageWorldChanged(instanceData)
- ClientData instanceData; /* Information about widget. */
+MessageWorldChanged(
+ ClientData instanceData) /* Information about widget. */
{
XGCValues gcValues;
GC gc = None;
@@ -563,8 +552,8 @@ MessageWorldChanged(instanceData)
}
/*
- * Recompute the desired geometry for the window, and arrange for
- * the window to be redisplayed.
+ * Recompute the desired geometry for the window, and arrange for the
+ * window to be redisplayed.
*/
ComputeMessageGeometry(msgPtr);
@@ -580,23 +569,22 @@ MessageWorldChanged(instanceData)
*
* ComputeMessageGeometry --
*
- * Compute the desired geometry for a message window,
- * taking into account the desired aspect ratio for the
- * window.
+ * Compute the desired geometry for a message window, taking into account
+ * the desired aspect ratio for the window.
*
* Results:
* None.
*
* Side effects:
- * Tk_GeometryRequest is called to inform the geometry
- * manager of the desired geometry for this window.
+ * Tk_GeometryRequest is called to inform the geometry manager of the
+ * desired geometry for this window.
*
*--------------------------------------------------------------
*/
static void
-ComputeMessageGeometry(msgPtr)
- register Message *msgPtr; /* Information about window. */
+ComputeMessageGeometry(
+ register Message *msgPtr) /* Information about window. */
{
int width, inc, height;
int thisWidth, thisHeight, maxWidth;
@@ -618,12 +606,11 @@ ComputeMessageGeometry(msgPtr)
upperBound = msgPtr->aspect + aspect;
/*
- * Do the computation in multiple passes: start off with
- * a very wide window, and compute its height. Then change
- * the width and try again. Reduce the size of the change
- * and iterate until dimensions are found that approximate
- * the desired aspect ratio. Or, if the user gave an explicit
- * width then just use that.
+ * Do the computation in multiple passes: start off with a very wide
+ * window, and compute its height. Then change the width and try again.
+ * Reduce the size of the change and iterate until dimensions are found
+ * that approximate the desired aspect ratio. Or, if the user gave an
+ * explicit width then just use that.
*/
if (msgPtr->width > 0) {
@@ -666,7 +653,7 @@ ComputeMessageGeometry(msgPtr)
*
* DisplayMessage --
*
- * This procedure redraws the contents of a message window.
+ * This function redraws the contents of a message window.
*
* Results:
* None.
@@ -678,8 +665,8 @@ ComputeMessageGeometry(msgPtr)
*/
static void
-DisplayMessage(clientData)
- ClientData clientData; /* Information about window. */
+DisplayMessage(
+ ClientData clientData) /* Information about window. */
{
register Message *msgPtr = (Message *) clientData;
register Tk_Window tkwin = msgPtr->tkwin;
@@ -703,8 +690,8 @@ DisplayMessage(clientData)
0, TK_RELIEF_FLAT);
/*
- * Compute starting y-location for message based on message size
- * and anchor option.
+ * Compute starting y-location for message based on message size and
+ * anchor option.
*/
TkComputeAnchor(msgPtr->anchor, tkwin, msgPtr->padX, msgPtr->padY,
@@ -724,7 +711,7 @@ DisplayMessage(clientData)
bgGC = Tk_GCForColor(msgPtr->highlightBgColorPtr, Tk_WindowId(tkwin));
if (msgPtr->flags & GOT_FOCUS) {
- fgGC = Tk_GCForColor(msgPtr->highlightColorPtr, Tk_WindowId(tkwin));
+ fgGC = Tk_GCForColor(msgPtr->highlightColorPtr,Tk_WindowId(tkwin));
TkpDrawHighlightBorder(tkwin, fgGC, bgGC, msgPtr->highlightWidth,
Tk_WindowId(tkwin));
} else {
@@ -739,23 +726,23 @@ DisplayMessage(clientData)
*
* MessageEventProc --
*
- * This procedure is invoked by the Tk dispatcher for various
- * events on messages.
+ * This function is invoked by the Tk dispatcher for various events on
+ * messages.
*
* Results:
* None.
*
* Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
+ * When the window gets deleted, internal structures get cleaned up.
+ * When it gets exposed, it is redisplayed.
*
*--------------------------------------------------------------
*/
static void
-MessageEventProc(clientData, eventPtr)
- ClientData clientData; /* Information about window. */
- XEvent *eventPtr; /* Information about event. */
+MessageEventProc(
+ ClientData clientData, /* Information about window. */
+ XEvent *eventPtr) /* Information about event. */
{
Message *msgPtr = (Message *) clientData;
@@ -781,7 +768,7 @@ MessageEventProc(clientData, eventPtr)
}
return;
- redraw:
+ redraw:
if ((msgPtr->tkwin != NULL) && !(msgPtr->flags & REDRAW_PENDING)) {
Tcl_DoWhenIdle(DisplayMessage, (ClientData) msgPtr);
msgPtr->flags |= REDRAW_PENDING;
@@ -793,9 +780,9 @@ MessageEventProc(clientData, eventPtr)
*
* MessageCmdDeletedProc --
*
- * This procedure is invoked when a widget command is deleted. If
- * the widget isn't already in the process of being destroyed,
- * this command destroys it.
+ * This function is invoked when a widget command is deleted. If the
+ * widget isn't already in the process of being destroyed, this command
+ * destroys it.
*
* Results:
* None.
@@ -807,16 +794,16 @@ MessageEventProc(clientData, eventPtr)
*/
static void
-MessageCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to widget record for widget. */
+MessageCmdDeletedProc(
+ ClientData clientData) /* Pointer to widget record for widget. */
{
Message *msgPtr = (Message *) clientData;
/*
- * This procedure could be invoked either because the window was
- * destroyed and the command was then deleted (in which case tkwin
- * is NULL) or because the command was deleted, and then this procedure
- * destroys the widget.
+ * This function could be invoked either because the window was destroyed
+ * and the command was then deleted (in which case tkwin is NULL) or
+ * because the command was deleted, and then this function destroys the
+ * widget.
*/
if (!(msgPtr->flags & MESSAGE_DELETED)) {
@@ -829,34 +816,33 @@ MessageCmdDeletedProc(clientData)
*
* MessageTextVarProc --
*
- * This procedure is invoked when someone changes the variable
- * whose contents are to be displayed in a message.
+ * This function is invoked when someone changes the variable whose
+ * contents are to be displayed in a message.
*
* Results:
* NULL is always returned.
*
* Side effects:
- * The text displayed in the message will change to match the
- * variable.
+ * The text displayed in the message will change to match the variable.
*
*--------------------------------------------------------------
*/
/* ARGSUSED */
static char *
-MessageTextVarProc(clientData, interp, name1, name2, flags)
- ClientData clientData; /* Information about message. */
- Tcl_Interp *interp; /* Interpreter containing variable. */
- CONST char *name1; /* Name of variable. */
- CONST char *name2; /* Second part of variable name. */
- int flags; /* Information about what happened. */
+MessageTextVarProc(
+ ClientData clientData, /* Information about message. */
+ Tcl_Interp *interp, /* Interpreter containing variable. */
+ CONST char *name1, /* Name of variable. */
+ CONST char *name2, /* Second part of variable name. */
+ int flags) /* Information about what happened. */
{
register Message *msgPtr = (Message *) clientData;
CONST char *value;
/*
- * If the variable is unset, then immediately recreate it unless
- * the whole interpreter is going away.
+ * If the variable is unset, then immediately recreate it unless the whole
+ * interpreter is going away.
*/
if (flags & TCL_TRACE_UNSETS) {
@@ -867,7 +853,7 @@ MessageTextVarProc(clientData, interp, name1, name2, flags)
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
MessageTextVarProc, clientData);
}
- return (char *) NULL;
+ return NULL;
}
value = Tcl_GetVar(interp, msgPtr->textVarName, TCL_GLOBAL_ONLY);
@@ -887,5 +873,13 @@ MessageTextVarProc(clientData, interp, name1, name2, flags)
Tcl_DoWhenIdle(DisplayMessage, (ClientData) msgPtr);
msgPtr->flags |= REDRAW_PENDING;
}
- return (char *) NULL;
+ return NULL;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */