Skip to content

Commit

Permalink
Use the more efficient Tk_AllocColorFromObj()/Tk_Alloc3DBorderFromObj…
Browse files Browse the repository at this point in the history
…()/Tk_AllocCursorFromObj()/Tk_GetJustifyFromObj() in tkOldConfig.c.

Merge 8.6
  • Loading branch information
jan.nijtmans committed Sep 1, 2024
2 parents 8685a0c + 3fec8cb commit 937d493
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 68 deletions.
80 changes: 39 additions & 41 deletions doc/3DBorder.3
Original file line number Diff line number Diff line change
Expand Up @@ -13,58 +13,49 @@ Tk_Alloc3DBorderFromObj, Tk_ClipDrawableToRect, Tk_DrawHighlightBorder, Tk_Get3D
.SH SYNOPSIS
.nf
\fB#include <tk.h>\fR
.sp

Tk_3DBorder
\fBTk_Alloc3DBorderFromObj(\fIinterp, tkwin, objPtr\fB)\fR
\fBTk_Alloc3DBorderFromObj\fR(\fIinterp, tkwin, objPtr\fR)
.sp
void
\fBTk_ClipDrawableToRect(\fIdisplay, drawable, x, y, width, height\fB)\fR
\fBTk_ClipDrawableToRect\fR(\fIdisplay, drawable, x, y, width, height\fR)
.sp
void
\fBTk_DrawHighlightBorder(\fItkwin, fgGC, bgGC, highlightWidth, drawable\fB)\fR
\fBTk_DrawHighlightBorder\fR(\fItkwin, fgGC, bgGC, highlightWidth, drawable\fR)
.sp
Tk_3DBorder
\fBTk_Get3DBorder(\fIinterp, tkwin, colorName\fB)\fR
\fBTk_Get3DBorder\fR(\fIinterp, tkwin, colorName\fR)
.sp
void
\fBTk_Get3DBorderColors(\fIborder, bgColorPtr, darkColorPtr, lightColorPtr\fB)\fR
\fBTk_Get3DBorderColors\fR(\fIborder, bgColorPtr, darkColorPtr, lightColorPtr\fR)
.sp
Tk_3DBorder
\fBTk_Get3DBorderFromObj(\fItkwin, objPtr\fB)\fR
\fBTk_Get3DBorderFromObj\fR(\fItkwin, objPtr\fR)
.sp
void
\fBTk_Draw3DRectangle(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fB)\fR
\fBTk_Draw3DRectangle\fR(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fR)
.sp
void
\fBTk_Fill3DRectangle(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fB)\fR
\fBTk_Fill3DRectangle\fR(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fR)
.sp
void
\fBTk_Draw3DPolygon(\fItkwin, drawable, border, pointPtr, numPoints, polyBorderWidth, leftRelief\fB)\fR
\fBTk_Draw3DPolygon\fR(\fItkwin, drawable, border, pointPtr, numPoints, polyBorderWidth, leftRelief\fR)
.sp
void
\fBTk_Fill3DPolygon(\fItkwin, drawable, border, pointPtr, numPoints, polyBorderWidth, leftRelief\fB)\fR
\fBTk_Fill3DPolygon\fR(\fItkwin, drawable, border, pointPtr, numPoints, polyBorderWidth, leftRelief\fR)
.sp
void
\fBTk_3DVerticalBevel\fR(\fItkwin, drawable, border, x, y, width, height, leftBevel, relief\fB)\fR
\fBTk_3DVerticalBevel\fR(\fItkwin, drawable, border, x, y, width, height, leftBevel, relief\fR)
.sp
void
\fBTk_3DHorizontalBevel\fR(\fItkwin, drawable, border, x, y, width, height, leftIn, rightIn, topBevel, relief\fB)\fR
\fBTk_3DHorizontalBevel\fR(\fItkwin, drawable, border, x, y, width, height, leftIn, rightIn, topBevel, relief\fR)
.sp
void
\fBTk_SetBackgroundFromBorder(\fItkwin, border\fB)\fR
\fBTk_SetBackgroundFromBorder\fR(\fItkwin, border\fR)
.sp
const char *
\fBTk_NameOf3DBorder(\fIborder\fB)\fR
\fBTk_NameOf3DBorder\fR(\fIborder\fR)
.sp
XColor *
\fBTk_3DBorderColor(\fIborder\fB)\fR
\fBTk_3DBorderColor\fR(\fIborder\fR)
.sp
GC *
\fBTk_3DBorderGC(\fItkwin, border, which\fB)\fR
\fBTk_3DBorderGC\fR(\fItkwin, border, which\fR)
.sp
\fBTk_Free3DBorderFromObj(\fItkwin, objPtr\fB)\fR
\fBTk_Free3DBorderFromObj\fR(\fItkwin, objPtr\fR)
.sp
\fBTk_Free3DBorder(\fIborder\fB)\fR
\fBTk_Free3DBorder\fR(\fIborder\fR)
.fi
.SH ARGUMENTS
.AS "Tk_3DBorder" borderWidth
.AP Tcl_Interp *interp in
Expand All @@ -76,7 +67,7 @@ must be the window for which the border was allocated).
Pointer to value whose value describes color corresponding to
background (flat areas). Illuminated edges will be brighter than
this and shadowed edges will be darker than this.
.AP char *colorName in
.AP "const char" *colorName in
Same as \fIobjPtr\fR except value is supplied as a string rather
than a value.
.AP Drawable drawable in
Expand All @@ -100,7 +91,8 @@ Width of border in pixels. Positive means border is inside rectangle
given by \fIx\fR, \fIy\fR, \fIwidth\fR, \fIheight\fR, negative means
border is outside rectangle.
.AP int highlightWidth in
Width of ring around the outside of the widget if the widget has received the input focus.
Width of ring around the outside of the widget if the widget has received the
input focus.
.AP int relief in
Indicates 3-D position of interior of value relative to exterior;
should be \fBTK_RELIEF_RAISED\fR, \fBTK_RELIEF_SUNKEN\fR, \fBTK_RELIEF_GROOVE\fR,
Expand Down Expand Up @@ -147,9 +139,11 @@ Must be \fBTK_3D_FLAT_GC\fR, \fBTK_3D_LIGHT_GC\fR, or \fBTK_3D_DARK_GC\fR.
.AP XColor *bgColorPtr out
Pointer to location in which to store the background color of the given border.
.AP XColor *darkColorPtr out
Pointer to location in which to store the color for darker areas of the given border.
Pointer to location in which to store the color for darker areas of the
given border.
.AP XColor *lightColorPtr out
Pointer to location in which to store the color for lighter areas of the given border.
Pointer to location in which to store the color for lighter areas of the
given border.
.AP GC fgGC in
Foreground X graphics context.
.AP GC fgGC in
Expand Down Expand Up @@ -180,12 +174,15 @@ information about the return value in \fIobjPtr\fR, which speeds up
future calls to \fBTk_Alloc3DBorderFromObj\fR with the same \fIobjPtr\fR
and \fItkwin\fR.
.PP
\fBTk_ClipDrawableToRect\fR will clip all drawing into the drawable d to the given rectangle. If width or height are negative, reset to no clipping.
Subsequent drawing into d is offset and clipped as specified.
The function is only used when \fBTK_NO_DOUBLE_BUFFERING\fR is specified at compile time.
\fBTk_ClipDrawableToRect\fR will clip all drawing into the drawable \fId\fR
to the given rectangle. If \fIwidth\fR or \fIheight\fR are negative, reset
to no clipping.
Subsequent drawing into \fId\fR is offset and clipped as specified.
The function is only used when \fBTK_NO_DOUBLE_BUFFERING\fR is specified at
compile time.
.PP
\fBTk_DrawHighlightBorder\fR draws a rectangular ring around the outside of a widget
to indicate that it has received the input focus.
\fBTk_DrawHighlightBorder\fR draws a rectangular ring around the outside of
a widget to indicate that it has received the input focus.
On the Macintosh, this puts a 1 pixel border in the bgGC color between
the widget and the focus ring, except in the case where highlightWidth
is 0 or 1, in which case the border is left out.
Expand Down Expand Up @@ -226,8 +223,8 @@ which of several three-dimensional effects is desired:
\fBTK_RELIEF_RAISED\fR means that the interior of the rectangle should
appear raised relative to the exterior of the rectangle, and
\fBTK_RELIEF_SUNKEN\fR means that the interior should appear depressed.
\fBTK_RELIEF_GROOVE\fR and \fBTK_RELIEF_RIDGE\fR mean that there should appear to be
a groove or ridge around the exterior of the rectangle.
\fBTK_RELIEF_GROOVE\fR and \fBTK_RELIEF_RIDGE\fR mean that there should
appear to be a groove or ridge around the exterior of the rectangle.
.PP
\fBTk_Fill3DRectangle\fR is somewhat like \fBTk_Draw3DRectangle\fR except
that it first fills the rectangular area with the background color
Expand Down Expand Up @@ -325,4 +322,5 @@ There should be exactly one call to \fBTk_Free3DBorderFromObj\fR or
\fBTk_Free3DBorder\fR for each call to \fBTk_Alloc3DBorderFromObj\fR
or \fBTk_Get3DBorder\fR.
.SH KEYWORDS
3D, background, border, color, depressed, illumination, value, polygon, raised, shadow, three-dimensional effect
3D, background, border, color, depressed, illumination, value, polygon,
raised, shadow, three-dimensional effect
21 changes: 12 additions & 9 deletions doc/GetColor.3
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@ Tk_AllocColorFromObj, Tk_GetColor, Tk_GetColorFromObj, Tk_GetColorByValue, Tk_Na
\fB#include <tk.h>\fR
.sp
XColor *
\fBTk_AllocColorFromObj(\fIinterp, tkwin, objPtr\fB)\fR
\fBTk_AllocColorFromObj\fR(\fIinterp, tkwin, objPtr\fR)
.sp
XColor *
\fBTk_GetColor(\fIinterp, tkwin, name\fB)\fR
\fBTk_GetColor\fR(\fIinterp, tkwin, name\fR)
.sp
XColor *
\fBTk_GetColorFromObj(\fItkwin, objPtr\fB)\fR
\fBTk_GetColorFromObj\fR(\fItkwin, objPtr\fR)
.sp
XColor *
\fBTk_GetColorByValue(\fItkwin, prefPtr\fB)\fR
\fBTk_GetColorByValue\fR(\fItkwin, prefPtr\fR)
.sp
const char *
\fBTk_NameOfColor(\fIcolorPtr\fB)\fR
\fBTk_NameOfColor\fR(\fIcolorPtr\fR)
.sp
GC
\fBTk_GCForColor(\fIcolorPtr, drawable\fB)\fR
\fBTk_GCForColor\fR(\fIcolorPtr, drawable\fR)
.sp
\fBTk_FreeColorFromObj(\fItkwin, objPtr\fB)\fR
\fBTk_FreeColorFromObj\fR(\fItkwin, objPtr\fR)
.sp
\fBTk_FreeColor(\fIcolorPtr\fB)\fR
\fBTk_FreeColor\fR(\fIcolorPtr\fR)
.fi
.SH ARGUMENTS
.AS "Tcl_Interp" *colorPtr
.AP Tcl_Interp *interp in
Expand All @@ -44,7 +45,7 @@ Token for window in which color will be used.
.AP Tcl_Obj *objPtr in/out
String value describes desired color; internal rep will be
modified to cache pointer to corresponding (XColor *).
.AP char *name in
.AP "const char" *name in
Same as \fIobjPtr\fR except description of color is passed as a string and
resulting (XColor *) is not cached.
.AP XColor *prefPtr in
Expand All @@ -71,6 +72,7 @@ in a particular window. The desired color is specified with a
value whose string value must have one of the following forms:
.TP 20
\fIcolorname\fR
.
Any of the valid textual names for a color defined in the
server's color database file, such as \fBred\fR or \fBPeachPuff\fR.
.TP 20
Expand All @@ -81,6 +83,7 @@ server's color database file, such as \fBred\fR or \fBPeachPuff\fR.
\fB#\fIRRRGGGBBB\fR
.TP 20
\fB#\fIRRRRGGGGBBBB\fR
.
A numeric specification of the red, green, and blue intensities
to use to display the color. Each \fIR\fR, \fIG\fR, or \fIB\fR
represents a single hexadecimal digit. The four forms permit
Expand Down
23 changes: 14 additions & 9 deletions doc/GetCursor.3
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ Tk_AllocCursorFromObj, Tk_GetCursor, Tk_GetCursorFromObj, Tk_GetCursorFromData,
\fB#include <tk.h>\fR
.sp
Tk_Cursor
\fBTk_AllocCursorFromObj(\fIinterp, tkwin, objPtr\fB)\fR
\fBTk_AllocCursorFromObj\fR(\fIinterp, tkwin, objPtr\fR)
.sp
Tk_Cursor
\fBTk_GetCursor(\fIinterp, tkwin, name\fB)\fR
\fBTk_GetCursor\fR(\fIinterp, tkwin, name\fR)
.sp
Tk_Cursor
\fBTk_GetCursorFromObj(\fItkwin, objPtr\fB)\fR
\fBTk_GetCursorFromObj\fR(\fItkwin, objPtr\fR)
.sp
Tk_Cursor
\fBTk_GetCursorFromData(\fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bg\fB)\fR
\fBTk_GetCursorFromData\fR(\fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bg\fR)
.sp
const char *
\fBTk_NameOfCursor(\fIdisplay, cursor\fB)\fR
\fBTk_NameOfCursor\fR(\fIdisplay, cursor\fR)
.sp
\fBTk_FreeCursorFromObj(\fItkwin, objPtr\fB)\fR
\fBTk_FreeCursorFromObj\fR(\fItkwin, objPtr\fR)
.sp
\fBTk_FreeCursor(\fIdisplay, cursor\fB)\fR
\fBTk_FreeCursor\fR(\fIdisplay, cursor\fR)
.fi
.SH ARGUMENTS
.AS "unsigned long" *pixelPtr
.AP Tcl_Interp *interp in
Expand All @@ -41,7 +42,7 @@ Token for window in which the cursor will be used.
.AP Tcl_Obj *objPtr in/out
Description of cursor; see below for possible values. Internal rep will be
modified to cache pointer to corresponding Tk_Cursor.
.AP char *name in
.AP "const char" *name in
Same as \fIobjPtr\fR except description of cursor is passed as a string and
resulting Tk_Cursor is not cached.
.AP "const char" *source in
Expand Down Expand Up @@ -87,6 +88,7 @@ if \fIinterp\fR is not NULL. \fIObjPtr\fR must contain a standard Tcl
list with one of the following forms:
.TP
\fIname\fR\0[\fIfgColor\fR\0[\fIbgColor\fR]]
.
\fIName\fR is the name of a cursor in the standard X cursor cursor,
i.e., any of the names defined in \fBcursorcursor.h\fR, without
the \fBXC_\fR. Some example values are \fBX_cursor\fR, \fBhand2\fR,
Expand Down Expand Up @@ -115,6 +117,7 @@ in preference to black and white cursors.
.RE
.TP
\fB@\fIsourceName\0maskName\0fgColor\0bgColor\fR
.
In this form, \fIsourceName\fR and \fImaskName\fR are the names of
files describing cursors for the cursor's source bits and mask.
Each file must be in standard X11 cursor format.
Expand All @@ -124,12 +127,14 @@ cursor, in any of the forms acceptable to \fBTk_GetColor\fR. This
form of the command will not work on Macintosh or Windows computers.
.TP
\fB@\fIsourceName\0fgColor\fR
.
This form is similar to the one above, except that the source is
used as mask also. This means that the cursor's background is
transparent. This form of the command will not work on Macintosh
or Windows computers.
.TP
\fB@\fIsourceName\fR
.
This form only works on Windows, and will load a Windows system
cursor (\fB.ani\fR or \fB.cur\fR) from the file specified in
\fIsourceName\fR.
Expand Down Expand Up @@ -196,7 +201,7 @@ argument that was passed to \fBTk_GetCursor\fR to create the
cursor. If \fIcursor\fR was created by a call to \fBTk_GetCursorFromData\fR,
or by any other mechanism, then the return value is a hexadecimal string
giving the X identifier for the cursor.
Note: the string returned by \fBTk_NameOfCursor\fR is
Note that the string returned by \fBTk_NameOfCursor\fR is
only guaranteed to persist until the next call to
\fBTk_NameOfCursor\fR. Also, this call is not portable except for
cursors returned by \fBTk_GetCursor\fR.
Expand Down
2 changes: 1 addition & 1 deletion doc/GetRelief.3
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ a string.
.AP int *reliefPtr out
Pointer to location in which to store relief value corresponding to
\fIobjPtr\fR or \fIname\fR.
.AP "const char" *name
.AP "const char" *name in
Name of the relief.
.AP int relief in
Relief value (one of \fBTK_RELIEF_FLAT\fR, \fBTK_RELIEF_RAISED\fR,
Expand Down
8 changes: 4 additions & 4 deletions generic/tkOldConfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ DoConfig(
if (nullValue) {
newPtr = NULL;
} else {
newPtr = Tk_GetColor(interp, tkwin, value);
newPtr = Tk_AllocColorFromObj(interp, tkwin, arg);
if (newPtr == NULL) {
return TCL_ERROR;
}
Expand Down Expand Up @@ -482,7 +482,7 @@ DoConfig(
if (nullValue) {
newBorder = NULL;
} else {
newBorder = Tk_Get3DBorder(interp, tkwin, value);
newBorder = Tk_Alloc3DBorderFromObj(interp, tkwin, arg);
if (newBorder == NULL) {
return TCL_ERROR;
}
Expand All @@ -506,7 +506,7 @@ DoConfig(
if (nullValue) {
newCursor = NULL;
} else {
newCursor = Tk_GetCursor(interp, tkwin, value);
newCursor = Tk_AllocCursorFromObj(interp, tkwin, arg);
if (newCursor == NULL) {
return TCL_ERROR;
}
Expand All @@ -522,7 +522,7 @@ DoConfig(
break;
}
case TK_CONFIG_JUSTIFY:
if (Tk_GetJustify(interp, value, (Tk_Justify *)ptr) != TCL_OK) {
if (Tk_GetJustifyFromObj(interp, arg, (Tk_Justify *)ptr) != TCL_OK) {
return TCL_ERROR;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion generic/tkText.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static const Tk_OptionSpec optionSpecs[] = {
offsetof(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_BORDER, "-inactiveselectbackground","inactiveSelectBackground",
"Foreground",
DEF_TEXT_INACTIVE_SELECT_COLOR,
DEF_TEXT_INACTIVE_SELECT_BG_COLOR,
TCL_INDEX_NONE, offsetof(TkText, inactiveSelBorder),
TK_OPTION_NULL_OK, DEF_TEXT_SELECT_MONO, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
Expand Down
2 changes: 1 addition & 1 deletion macosx/tkMacOSXDefault.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@
#define DEF_TEXT_PADX "1"
#define DEF_TEXT_PADY "1"
#define DEF_TEXT_RELIEF "flat"
#define DEF_TEXT_INACTIVE_SELECT_COLOR INACTIVE_SELECT_BG
#define DEF_TEXT_INACTIVE_SELECT_BG_COLOR INACTIVE_SELECT_BG
#define DEF_TEXT_SELECT_COLOR SELECT_BG
#define DEF_TEXT_SELECT_MONO BLACK
#define DEF_TEXT_SELECT_BD_COLOR "1"
Expand Down
2 changes: 1 addition & 1 deletion unix/tkUnixDefault.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@
#define DEF_TEXT_PADX "1"
#define DEF_TEXT_PADY "1"
#define DEF_TEXT_RELIEF "sunken"
#define DEF_TEXT_INACTIVE_SELECT_COLOR SELECT_BG
#define DEF_TEXT_INACTIVE_SELECT_BG_COLOR SELECT_BG
#define DEF_TEXT_SELECT_COLOR SELECT_BG
#define DEF_TEXT_SELECT_MONO BLACK
#define DEF_TEXT_SELECT_BD_COLOR "0"
Expand Down
2 changes: 1 addition & 1 deletion win/tkWinDefault.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@
#define DEF_TEXT_PADX "1"
#define DEF_TEXT_PADY "1"
#define DEF_TEXT_RELIEF "sunken"
#define DEF_TEXT_INACTIVE_SELECT_COLOR NULL
#define DEF_TEXT_INACTIVE_SELECT_BG_COLOR NULL
#define DEF_TEXT_SELECT_COLOR SELECT_BG
#define DEF_TEXT_SELECT_MONO BLACK
#define DEF_TEXT_SELECT_BD_COLOR "0"
Expand Down

0 comments on commit 937d493

Please sign in to comment.