Import Tk 8.6.11

This commit is contained in:
Steve Dower
2021-03-30 00:54:10 +01:00
parent 42c69189d9
commit 070b8750b0
403 changed files with 21608 additions and 16269 deletions

View File

@@ -3,7 +3,7 @@
* Minimal sample ttk widget.
*/
#include <tk.h>
#include "tkInt.h"
#include "ttkTheme.h"
#include "ttkWidget.h"
@@ -56,24 +56,24 @@ static Tk_OptionSpec SquareOptionSpecs[] =
{TK_OPTION_BORDER, "-foreground", "foreground", "Foreground",
DEFAULT_BACKGROUND, Tk_Offset(Square,square.foregroundObj),
-1, 0, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
"50", Tk_Offset(Square,square.widthObj), -1, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_PIXELS, "-height", "height", "Height",
"50", Tk_Offset(Square,square.heightObj), -1, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-padding", "padding", "Pad", NULL,
Tk_Offset(Square,square.paddingObj), -1,
Tk_Offset(Square,square.paddingObj), -1,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
NULL, Tk_Offset(Square,square.reliefObj), -1, TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
NULL, Tk_Offset(Square,square.anchorObj), -1, TK_OPTION_NULL_OK, 0, 0},
WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
@@ -109,7 +109,7 @@ SquareDoLayout(void *clientData)
*/
if (squareNode) {
Square *squarePtr = clientData;
Square *squarePtr = (Square *)clientData;
Tk_Anchor anchor = TK_ANCHOR_CENTER;
Ttk_Box b;
@@ -138,7 +138,7 @@ static const Ttk_Ensemble SquareCommands[] = {
};
/*
* The Widget specification structure holds all the implementation
* The Widget specification structure holds all the implementation
* information about this widget and this is what must be registered
* with Tk in the package initialization code (see bottom).
*/
@@ -159,7 +159,7 @@ static WidgetSpec SquareWidgetSpec =
TtkWidgetDisplay /* displayProc */
};
/* ----------------------------------------------------------------------
/* ----------------------------------------------------------------------
* Square element
*
* In this section we demonstrate what is required to create a new themed
@@ -176,7 +176,7 @@ typedef struct
Tcl_Obj *heightObj;
} SquareElement;
static Ttk_ElementOptionSpec SquareElementOptions[] =
static Ttk_ElementOptionSpec SquareElementOptions[] =
{
{ "-background", TK_OPTION_BORDER, Tk_Offset(SquareElement,borderObj),
DEFAULT_BACKGROUND },
@@ -188,7 +188,7 @@ static Ttk_ElementOptionSpec SquareElementOptions[] =
"raised" },
{ "-width", TK_OPTION_PIXELS, Tk_Offset(SquareElement,widthObj), "20"},
{ "-height", TK_OPTION_PIXELS, Tk_Offset(SquareElement,heightObj), "20"},
{ NULL, 0, 0, NULL }
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
/*
@@ -198,11 +198,12 @@ static Ttk_ElementOptionSpec SquareElementOptions[] =
*/
static void SquareElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
SquareElement *square = elementRecord;
SquareElement *square = (SquareElement *)elementRecord;
int borderWidth = 0;
(void)dummy;
Tcl_GetIntFromObj(NULL, square->borderWidthObj, &borderWidth);
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
@@ -215,12 +216,14 @@ static void SquareElementSize(
*/
static void SquareElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
SquareElement *square = elementRecord;
SquareElement *square = (SquareElement *)elementRecord;
Tk_3DBorder foreground = NULL;
int borderWidth = 1, relief = TK_RELIEF_FLAT;
(void)dummy;
(void)state;
foreground = Tk_Get3DBorderFromObj(tkwin, square->foregroundObj);
Tcl_GetIntFromObj(NULL, square->borderWidthObj, &borderWidth);
@@ -248,7 +251,7 @@ static Ttk_ElementSpec SquareElementSpec =
* engine is similar to the Tk pack geometry manager. Read the documentation
* for the details. In this example we just need to have the square element
* that has been defined for this widget placed on a background. We will
* also need some padding to keep it away from the edges.
* also need some padding to keep it away from the edges.
*/
TTK_BEGIN_LAYOUT(SquareLayout)
@@ -257,12 +260,12 @@ TTK_BEGIN_LAYOUT(SquareLayout)
TTK_NODE("Square.square", 0))
TTK_END_LAYOUT
/* ----------------------------------------------------------------------
/* ----------------------------------------------------------------------
*
* Widget initialization.
*
* This file defines a new element and a new widget. We need to register
* the element with the themes that will need it. In this case we will
* the element with the themes that will need it. In this case we will
* register with the default theme that is the root of the theme inheritance
* tree. This means all themes will find this element.
* We then need to register the widget class style. This is the layout
@@ -287,10 +290,10 @@ TtkSquareWidget_Init(Tcl_Interp *interp)
/* register the new elements for this theme engine */
Ttk_RegisterElement(interp, theme, "square", &SquareElementSpec, NULL);
/* register the layout for this theme */
Ttk_RegisterLayout(theme, "TSquare", SquareLayout);
/* register the widget */
RegisterWidget(interp, "ttk::square", &SquareWidgetSpec);