tkUtil.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/*
* tkUtil.c --
*
* This file contains miscellaneous utility procedures that
* are used by the rest of Tk, such as a procedure for drawing
* a focus highlight.
*
* Copyright (c) 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: @(#) tkUtil.c 1.8 96/08/21 17:45:36
*/
#include "tkInt.h"
/*
*----------------------------------------------------------------------
*
* Tk_DrawFocusHighlight --
*
* This procedure draws a rectangular ring around the outside of
* a widget to indicate that it has received the input focus.
*
* Results:
* None.
*
* Side effects:
* A rectangle "width" pixels wide is drawn in "drawable",
* corresponding to the outer area of "tkwin".
*
*----------------------------------------------------------------------
*/
void
* to be drawn. */
* the highlight ring. */
int width; /* Width of the highlight ring, in pixels. */
* pixmap for double buffering). */
{
rects[0].x = 0;
rects[0].y = 0;
rects[1].x = 0;
rects[2].x = 0;
}
/*
*----------------------------------------------------------------------
*
* Tk_GetScrollInfo --
*
* This procedure is invoked to parse "xview" and "yview"
* scrolling commands for widgets using the new scrolling
* command syntax ("moveto" or "scroll" options).
*
* Results:
* The return value is either TK_SCROLL_MOVETO, TK_SCROLL_PAGES,
* TK_SCROLL_UNITS, or TK_SCROLL_ERROR. This indicates whether
* the command was successfully parsed and what form the command
* took. If TK_SCROLL_MOVETO, *dblPtr is filled in with the
* desired position; if TK_SCROLL_PAGES or TK_SCROLL_UNITS,
* *intPtr is filled in with the number of lines to move (may be
* negative); if TK_SCROLL_ERROR, interp->result contains an
* error message.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
int argc; /* # arguments for command. */
char **argv; /* Arguments for command. */
double *dblPtr; /* Filled in with argument "moveto"
* option, if any. */
int *intPtr; /* Filled in with number of pages
* or lines to scroll, if any. */
{
int c;
c = argv[2][0];
if (argc != 4) {
(char *) NULL);
return TK_SCROLL_ERROR;
}
return TK_SCROLL_ERROR;
}
return TK_SCROLL_MOVETO;
} else if ((c == 's')
if (argc != 5) {
(char *) NULL);
return TK_SCROLL_ERROR;
}
return TK_SCROLL_ERROR;
}
c = argv[4][0];
return TK_SCROLL_PAGES;
} else if ((c == 'u')
return TK_SCROLL_UNITS;
} else {
"\": must be units or pages", (char *) NULL);
return TK_SCROLL_ERROR;
}
}
"\": must be moveto or scroll", (char *) NULL);
return TK_SCROLL_ERROR;
}
/*
*---------------------------------------------------------------------------
*
* TkFindStateString --
*
* Given a lookup table, map a number to a string in the table.
*
* Results:
* If numKey was equal to the numeric key of one of the elements
* in the table, returns the string key of that element.
* Returns NULL if numKey was not equal to any of the numeric keys
* in the table.
*
* Side effects.
* None.
*
*---------------------------------------------------------------------------
*/
char *
int numKey; /* The key to try to find in the table. */
{
}
}
return NULL;
}
/*
*---------------------------------------------------------------------------
*
* TkFindStateNum --
*
* Given a lookup table, map a string to a number in the table.
*
* Results:
* If strKey was equal to the string keys of one of the elements
* in the table, returns the numeric key of that element.
* Returns the numKey associated with the last element (the NULL
* string one) in the table if strKey was not equal to any of the
* string keys in the table. In that case, an error message is
* also left in interp->result (if interp is not NULL).
*
* Side effects.
* None.
*
*---------------------------------------------------------------------------
*/
int
{
panic("TkFindStateNum: no choices in lookup table");
}
}
}
}
}
}