/*
* tkFrame.c --
*
* This module implements "frame" and "toplevel" widgets for
* the Tk toolkit. Frames are windows with a background color
* and possibly a 3-D effect, but not much else in the way of
* attributes.
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1995 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* SCCS: @(#) tkFrame.c 1.68 96/02/15 18:53:30
*/
#include "tkInt.h"
#include "tkDefault.h"
/*
* A data structure of the following type is kept for each
* frame that currently exists for this process:
*/
typedef struct {
* means that the window has been destroyed
* but the data structures haven't yet been
* cleaned up. */
* other things, so that resources can be
* freed even after tkwin has gone away. */
* to delete widget command. */
* option). Malloc-ed. */
* which configuration options are valid for
* widget. */
* only for top-levels. Malloc-ed, may be
* NULL. */
* from -visual option. Malloc-ed, may be
* NULL. */
* from -colormap option. Malloc-ed, may be
* NULL. */
* allocated for this window, which must be
* freed when the window is deleted. */
* background. NULL means no background
* or border. */
* around widget when it has the focus.
* 0 means don't draw a highlight. */
/* Color for drawing traversal highlight
* area when highlight is off. */
* don't request any size. */
* don't request any size. */
* the C code, but used by keyboard traversal
* scripts. Malloc'ed, but may be NULL. */
* definitions. */
} Frame;
/*
* Flag bits for frames:
*
* REDRAW_PENDING: Non-zero means a DoWhenIdle handler
* has already been queued to redraw
* this window.
* GOT_FOCUS: Non-zero means this widget currently
* has the input focus.
*/
/*
* The following flag bits are used so that there can be separate
* defaults for some configuration options for frames and toplevels.
*/
"HighlightBackground", DEF_FRAME_HIGHLIGHT_BG,
"HighlightThickness",
(char *) NULL, 0, 0}
};
/*
* Forward declarations for procedures defined later in this file:
*/
int flags));
static void FrameCmdDeletedProc _ANSI_ARGS_((
/*
*--------------------------------------------------------------
*
* Tk_FrameCmd, Tk_ToplevelCmd --
*
* These procedures are invoked to process the "frame" and
* "toplevel" Tcl commands. See the user documentation for
* details on what they do.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation. These procedures are just wrappers;
* they call ButtonCreate to do all of the real work.
*
*--------------------------------------------------------------
*/
int
* interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
}
int
* interpreter. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
}
/*
*--------------------------------------------------------------
*
* TkFrameCreate --
*
* This procedure is invoked to process the "frame" and "toplevel"
* Tcl commands; it is also invoked directly by Tk_Init to create
* a new main window. See the user documentation for the "frame"
* and "toplevel" commands for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*--------------------------------------------------------------
*/
int
* If we're called by Tk_Init to create a
* new application, then this is NULL. */
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
int toplevel; /* Non-zero means create a toplevel window,
* zero means create a frame. */
char *appName; /* Should only be non-NULL if clientData is
* NULL: gives the base name to use for the
* new application. */
{
if (argc < 2) {
return TCL_ERROR;
}
/*
* Pre-process the argument list. Scan through it to find any
* "-class", "-screen", "-visual", and "-colormap" options. These
* arguments need to be processed specially, before the window
* is configured using the usual Tk mechanisms.
*/
if (length < 2) {
continue;
}
c = arg[1];
&& (length >= 3)) {
} else if ((c == 'c')
} else if ((c == 's') && toplevel
} else if ((c == 'v')
}
}
/*
* Create the window, and deal with the special options -classname,
* -colormap, -screenname, and -visual. The order here is tricky,
* because we want to allow values for these options to come from
* the database, yet we can't do that until the window is created.
*/
if (screenName == NULL) {
}
} else {
/*
* We were called from Tk_Init; create a new application.
*/
panic("TkCreateFrame didn't get application name");
}
}
goto error;
}
}
}
if (visualName == NULL) {
}
if (colormapName == NULL) {
}
if (visualName != NULL) {
goto error;
}
}
if (colormapName != NULL) {
goto error;
}
}
/*
* For top-level windows, provide an initial geometry request of
* 200x200, just so the window looks nicer on the screen if it
* doesn't request a size for itself.
*/
if (toplevel) {
}
/*
* Create the widget record, process configuration options, and
* create event handlers. Then fill in a few additional fields
* in the widget record from the special options.
*/
framePtr->borderWidth = 0;
framePtr->highlightWidth = 0;
goto error;
}
if (toplevel) {
}
return TCL_OK;
}
return TCL_ERROR;
}
/*
*--------------------------------------------------------------
*
* FrameWidgetCmd --
*
* This procedure is invoked to process the Tcl command
* that corresponds to a frame widget. See the user
* documentation for details on what it does.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*
*--------------------------------------------------------------
*/
static int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
int c, i;
if (argc < 2) {
return TCL_ERROR;
}
c = argv[1][0];
&& (length >= 2)) {
if (argc != 3) {
argv[0], " cget option\"",
(char *) NULL);
goto done;
}
&& (length >= 2)) {
if (argc == 2) {
} else if (argc == 3) {
} else {
/*
* Don't allow the options -class, -newcmap, -screen,
* or -visual to be changed.
*/
for (i = 2; i < argc; i++) {
if (length < 2) {
continue;
}
c = argv[i][1];
&& (length >= 2))
" option after widget is created", (char *) NULL);
goto done;
}
}
}
} else {
"\": must be cget or configure", (char *) NULL);
}
done:
return result;
}
/*
*----------------------------------------------------------------------
*
* DestroyFrame --
*
* This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
* to clean up the internal structure of a frame at a safe time
* (when no-one is using it anymore).
*
* Results:
* None.
*
* Side effects:
* Everything associated with the frame is freed up.
*
*----------------------------------------------------------------------
*/
static void
char *memPtr; /* Info about frame widget. */
{
}
}
/*
*----------------------------------------------------------------------
*
* ConfigureFrame --
*
* the Tk option database, in order to configure (or
* reconfigure) a frame widget.
*
* Results:
* The return value is a standard Tcl result. If TCL_ERROR is
* returned, then interp->result contains an error message.
*
* Side effects:
* Configuration information, such as text string, colors, font,
* etc. get set for framePtr; old resources get freed, if there
* were any.
*
*----------------------------------------------------------------------
*/
static int
* not already have values for some fields. */
int argc; /* Number of valid entries in argv. */
char **argv; /* Arguments. */
int flags; /* Flags to pass to Tk_ConfigureWidget. */
{
return TCL_ERROR;
}
}
if (framePtr->highlightWidth < 0) {
framePtr->highlightWidth = 0;
}
}
}
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* DisplayFrame --
*
* This procedure is invoked to display a frame widget.
*
* Results:
* None.
*
* Side effects:
* Commands are output to X to display the frame in its
* current mode.
*
*----------------------------------------------------------------------
*/
static void
{
return;
}
}
if (framePtr->highlightWidth != 0) {
Tk_WindowId(tkwin));
} else {
Tk_WindowId(tkwin));
}
Tk_WindowId(tkwin));
}
}
/*
*--------------------------------------------------------------
*
* FrameEventProc --
*
* This procedure is invoked by the Tk dispatcher on
* structure changes to a frame. For frames with 3D
* borders, this procedure is also invoked for exposures.
*
* Results:
* None.
*
* Side effects:
* When the window gets deleted, internal structures get
* cleaned up. When it gets exposed, it is redisplayed.
*
*--------------------------------------------------------------
*/
static void
{
goto redraw;
}
}
if (framePtr->highlightWidth > 0) {
goto redraw;
}
}
if (framePtr->highlightWidth > 0) {
goto redraw;
}
}
}
return;
}
}
/*
*----------------------------------------------------------------------
*
* FrameCmdDeletedProc --
*
* 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.
*
* Results:
* None.
*
* Side effects:
* The widget is destroyed.
*
*----------------------------------------------------------------------
*/
static void
{
/*
* 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.
*/
}
}
/*
*----------------------------------------------------------------------
*
* MapFrame --
*
* This procedure is invoked as a when-idle handler to map a
* newly-created top-level frame.
*
* Results:
* None.
*
* Side effects:
* The frame given by the clientData argument is mapped.
*
*----------------------------------------------------------------------
*/
static void
{
/*
* Wait for all other background events to be processed before
* mapping window. This ensures that the window's correct geometry
* will have been determined before it is first mapped, so that the
* window manager doesn't get a false idea of its desired geometry.
*/
while (1) {
if (Tcl_DoOneEvent(TCL_IDLE_EVENTS) == 0) {
break;
}
/*
* After each event, make sure that the window still exists
* and quit if the window has been destroyed.
*/
return;
}
}
}