diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-10-24 20:59:23 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-10-24 20:59:23 (GMT) |
commit | 5681e1e0897c2f74906150209d8c0df7884921b3 (patch) | |
tree | 61696df26694b937b6c74e1194ffceb81ef554ff /generic/tk.h | |
parent | f4d4ea253a43c4d3d8ba006a4382bac86b94dbf8 (diff) | |
parent | 6dbd27622fc3c65d43c7e6b05ab465583f619298 (diff) | |
download | tk-5681e1e0897c2f74906150209d8c0df7884921b3.zip tk-5681e1e0897c2f74906150209d8c0df7884921b3.tar.gz tk-5681e1e0897c2f74906150209d8c0df7884921b3.tar.bz2 |
Adapt to TIP #628 (mainly TkSizeT -> Tcl_Size)
Diffstat (limited to 'generic/tk.h')
-rw-r--r-- | generic/tk.h | 211 |
1 files changed, 71 insertions, 140 deletions
diff --git a/generic/tk.h b/generic/tk.h index 9697a9c..581aad5 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -65,7 +65,12 @@ extern "C" { * the version of Tcl that this release of Tk is compiled against. */ -#define TK_MAJOR_VERSION 8 +#ifndef TK_MAJOR_VERSION +# define TK_MAJOR_VERSION 8 +#endif +#if TK_MAJOR_VERSION != 8 +# error "This header-file is for Tk 8 only" +#endif #define TK_MINOR_VERSION 7 #define TK_RELEASE_LEVEL TCL_ALPHA_RELEASE #define TK_RELEASE_SERIAL 6 @@ -141,6 +146,10 @@ typedef struct Tk_StyledElement_ *Tk_StyledElement; */ typedef const char *Tk_Uid; + +#ifndef Tcl_Size +# define Tcl_Size int +#endif /* *---------------------------------------------------------------------- @@ -190,14 +199,13 @@ typedef struct Tk_OptionSpec { const char *defValue; /* Default value for option if not specified * in command line, the option database, or * the system. */ -#if TCL_MAJOR_VERSION > 8 - size_t objOffset; /* Where in record to store a Tcl_Obj * that + Tcl_Size objOffset; /* Where in record to store a Tcl_Obj * that * holds the value of this option, specified * as an offset in bytes from the start of the * record. Use the offsetof macro to generate * values for this. TCL_INDEX_NONE means don't * store the Tcl_Obj in the record. */ - size_t internalOffset; /* Where in record to store the internal + Tcl_Size internalOffset; /* Where in record to store the internal * representation of the value of this option, * such as an int or XColor *. This field is * specified as an offset in bytes from the @@ -205,10 +213,6 @@ typedef struct Tk_OptionSpec { * macro to generate values for it. * TCL_INDEX_NONE means don't store the * internal representation in the record. */ -#else - int objOffset; - int internalOffset; -#endif int flags; /* Any combination of the values defined * below. */ const void *clientData; /* An alternate place to put option-specific @@ -239,22 +243,14 @@ typedef struct Tk_OptionSpec { * option config code to handle a custom option. */ -#if TCL_MAJOR_VERSION > 8 -typedef int (Tk_CustomOptionSetProc) (ClientData clientData, - Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *widgRec, - size_t offset, char *saveInternalPtr, int flags); -typedef Tcl_Obj *(Tk_CustomOptionGetProc) (ClientData clientData, - Tk_Window tkwin, char *widgRec, size_t offset); -#else -typedef int (Tk_CustomOptionSetProc) (ClientData clientData, +typedef int (Tk_CustomOptionSetProc) (void *clientData, Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *widgRec, - int offset, char *saveInternalPtr, int flags); -typedef Tcl_Obj *(Tk_CustomOptionGetProc) (ClientData clientData, - Tk_Window tkwin, char *widgRec, int offset); -#endif -typedef void (Tk_CustomOptionRestoreProc) (ClientData clientData, + Tcl_Size offset, char *saveInternalPtr, int flags); +typedef Tcl_Obj *(Tk_CustomOptionGetProc) (void *clientData, + Tk_Window tkwin, char *widgRec, Tcl_Size offset); +typedef void (Tk_CustomOptionRestoreProc) (void *clientData, Tk_Window tkwin, char *internalPtr, char *saveInternalPtr); -typedef void (Tk_CustomOptionFreeProc) (ClientData clientData, Tk_Window tkwin, +typedef void (Tk_CustomOptionFreeProc) (void *clientData, Tk_Window tkwin, char *internalPtr); typedef struct Tk_ObjCustomOption { @@ -272,7 +268,7 @@ typedef struct Tk_ObjCustomOption { Tk_CustomOptionFreeProc *freeProc; /* Function to use to free the internal * representation of an option. */ - ClientData clientData; /* Arbitrary one-word value passed to the + void *clientData; /* Arbitrary one-word value passed to the * handling procs. */ } Tk_ObjCustomOption; @@ -327,11 +323,7 @@ typedef struct Tk_SavedOptions { * configuration options. */ Tk_Window tkwin; /* Window associated with recordPtr; needed to * restore certain options. */ -#if TCL_MAJOR_VERSION > 8 - size_t numItems; /* The number of valid items in items field. */ -#else - int numItems; -#endif + Tcl_Size numItems; /* The number of valid items in items field. */ Tk_SavedOption items[TK_NUM_SAVED_OPTIONS]; /* Items used to hold old values. */ struct Tk_SavedOptions *nextPtr; @@ -355,17 +347,10 @@ typedef struct Tk_SavedOptions { #ifndef __NO_OLD_CONFIG -#if TCL_MAJOR_VERSION > 8 -typedef int (Tk_OptionParseProc) (ClientData clientData, Tcl_Interp *interp, - Tk_Window tkwin, const char *value, char *widgRec, size_t offset); -typedef const char *(Tk_OptionPrintProc) (ClientData clientData, - Tk_Window tkwin, char *widgRec, size_t offset, Tcl_FreeProc **freeProcPtr); -#else -typedef int (Tk_OptionParseProc) (ClientData clientData, Tcl_Interp *interp, - Tk_Window tkwin, const char *value, char *widgRec, int offset); -typedef const char *(Tk_OptionPrintProc) (ClientData clientData, - Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); -#endif +typedef int (Tk_OptionParseProc) (void *clientData, Tcl_Interp *interp, + Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset); +typedef const char *(Tk_OptionPrintProc) (void *clientData, + Tk_Window tkwin, char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr); typedef struct Tk_CustomOption { Tk_OptionParseProc *parseProc; @@ -374,7 +359,7 @@ typedef struct Tk_CustomOption { Tk_OptionPrintProc *printProc; /* Procedure to return a printable string * describing an existing option. */ - ClientData clientData; /* Arbitrary one-word value used by option + void *clientData; /* Arbitrary one-word value used by option * parser: passed to parseProc and * printProc. */ } Tk_CustomOption; @@ -396,13 +381,9 @@ typedef struct Tk_ConfigSpec { Tk_Uid dbClass; /* Class for option in database. */ Tk_Uid defValue; /* Default value for option if not specified * in command line or database. */ -#if TCL_MAJOR_VERSION > 8 - size_t offset; /* Where in widget record to store value; use + Tcl_Size offset; /* Where in widget record to store value; use * offsetof macro to generate values for * this. */ -#else - int offset; -#endif int specFlags; /* Any combination of the values defined * below; other bits are used internally by * tkConfig.c. */ @@ -606,16 +587,12 @@ typedef struct Tk_FontMetrics { */ typedef Window (Tk_ClassCreateProc) (Tk_Window tkwin, Window parent, - ClientData instanceData); -typedef void (Tk_ClassWorldChangedProc) (ClientData instanceData); + void *instanceData); +typedef void (Tk_ClassWorldChangedProc) (void *instanceData); typedef void (Tk_ClassModalProc) (Tk_Window tkwin, XEvent *eventPtr); typedef struct Tk_ClassProcs { -#if TCL_MAJOR_VERSION > 8 - size_t size; -#else - unsigned int size; -#endif + Tcl_Size size; Tk_ClassWorldChangedProc *worldChangedProc; /* Procedure to invoke when the widget needs * to respond in some way to a change in the @@ -640,12 +617,12 @@ typedef struct Tk_ClassProcs { * * #define Tk_GetField(name, who, which) \ * (((who) == NULL) ? NULL : - * (((who)->size <= offsetof(name, which)) ? NULL :(name)->which)) + * (((size_t)(who)->size <= offsetof(name, which)) ? NULL :(name)->which)) */ #define Tk_GetClassProc(procs, which) \ (((procs) == NULL) ? NULL : \ - (((procs)->size <= offsetof(Tk_ClassProcs, which)) ? NULL:(procs)->which)) + (((size_t)(procs)->size <= offsetof(Tk_ClassProcs, which)) ? NULL:(procs)->which)) /* * Each geometry manager (the packer, the placer, etc.) is represented by a @@ -654,8 +631,8 @@ typedef struct Tk_ClassProcs { */ #define Tk_GeomLostSlaveProc Tk_GeomLostContentProc -typedef void (Tk_GeomRequestProc) (ClientData clientData, Tk_Window tkwin); -typedef void (Tk_GeomLostContentProc) (ClientData clientData, Tk_Window tkwin); +typedef void (Tk_GeomRequestProc) (void *clientData, Tk_Window tkwin); +typedef void (Tk_GeomLostContentProc) (void *clientData, Tk_Window tkwin); typedef struct Tk_GeomMgr { const char *name; /* Name of the geometry manager (command used @@ -838,22 +815,17 @@ typedef struct Tk_FakeWin { #if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8) XIC dummy9; /* inputContext */ #endif /* TK_USE_INPUT_METHODS */ - ClientData *dummy10; /* tagPtr */ -#if TCL_MAJOR_VERSION > 8 - size_t dummy11; /* numTags */ - size_t dummy12; /* optionLevel */ -#else - int dummy11; - int dummy12; -#endif + void **dummy10; /* tagPtr */ + Tcl_Size dummy11; /* numTags */ + Tcl_Size dummy12; /* optionLevel */ char *dummy13; /* selHandlerList */ char *dummy14; /* geomMgrPtr */ - ClientData dummy15; /* geomData */ + void *dummy15; /* geomData */ int reqWidth, reqHeight; int internalBorderLeft; char *dummy16; /* wmInfoPtr */ char *dummy17; /* classProcPtr */ - ClientData dummy18; /* instanceData */ + void *dummy18; /* instanceData */ char *dummy19; /* privatePtr */ int internalBorderRight; int internalBorderTop; @@ -992,12 +964,8 @@ typedef struct Tk_SmoothMethod { #define TK_TAG_SPACE 3 typedef struct Tk_Item { -#if TCL_MAJOR_VERSION > 8 - size_t id; /* Unique identifier for this item (also + Tcl_Size id; /* Unique identifier for this item (also * serves as first tag for item). */ -#else - int id; -#endif struct Tk_Item *nextPtr; /* Next in display list of all items in this * canvas. Later items in list are drawn on * top of earlier ones. */ @@ -1006,14 +974,10 @@ typedef struct Tk_Item { Tk_Uid *tagPtr; /* Pointer to array of tags. Usually points to * staticTagSpace, but may point to malloc-ed * space if there are lots of tags. */ -#if TCL_MAJOR_VERSION > 8 - size_t tagSpace; /* Total amount of tag space available at + Tcl_Size tagSpace; /* Total amount of tag space available at * tagPtr. */ - size_t numTags; /* Number of tag slots actually used at + Tcl_Size numTags; /* Number of tag slots actually used at * *tagPtr. */ -#else - int tagSpace, numTags; -#endif struct Tk_ItemType *typePtr;/* Table of procedures that implement this * type of item. */ int x1, y1, x2, y2; /* Bounding box for item, in integer canvas @@ -1075,17 +1039,10 @@ typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas, int flags); typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); -#if TCL_MAJOR_VERSION > 8 -typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr, - size_t beforeThis, Tcl_Obj *string); -typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, - Tk_Item *itemPtr, Tcl_Obj *indexString, size_t *indexPtr); -#else typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr, - int beforeThis, Tcl_Obj *string); + Tcl_Size beforeThis, Tcl_Obj *string); typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, - Tk_Item *itemPtr, Tcl_Obj *indexString, int *indexPtr); -#endif + Tk_Item *itemPtr, Tcl_Obj *indexString, Tcl_Size *indexPtr); #endif /* USE_OLD_CANVAS */ typedef void (Tk_ItemDeleteProc)(Tk_Canvas canvas, Tk_Item *itemPtr, Display *display); @@ -1105,33 +1062,20 @@ typedef void (Tk_ItemScaleProc)(Tk_Canvas canvas, Tk_Item *itemPtr, double scaleY); typedef void (Tk_ItemTranslateProc)(Tk_Canvas canvas, Tk_Item *itemPtr, double deltaX, double deltaY); -#if TCL_MAJOR_VERSION > 8 -typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr, - size_t index); -typedef size_t (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr, - size_t offset, char *buffer, size_t maxBytes); -typedef void (Tk_ItemDCharsProc)(Tk_Canvas canvas, Tk_Item *itemPtr, - size_t first, size_t last); -#else typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr, - int index); -typedef int (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr, - int offset, char *buffer, int maxBytes); + Tcl_Size index); +typedef Tcl_Size (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr, + Tcl_Size offset, char *buffer, Tcl_Size maxBytes); typedef void (Tk_ItemDCharsProc)(Tk_Canvas canvas, Tk_Item *itemPtr, - int first, int last); -#endif + Tcl_Size first, Tcl_Size last); #ifndef __NO_OLD_CONFIG typedef struct Tk_ItemType { const char *name; /* The name of this type of item, such as * "line". */ -#if TCL_MAJOR_VERSION > 8 - size_t itemSize; /* Total amount of space needed for item's + Tcl_Size itemSize; /* Total amount of space needed for item's * record. */ -#else - int itemSize; -#endif Tk_ItemCreateProc *createProc; /* Procedure to create a new item of this * type. */ @@ -1213,25 +1157,17 @@ typedef struct Tk_CanvasTextInfo { Tk_Item *selItemPtr; /* Pointer to selected item. NULL means * selection isn't in this canvas. Writable by * items. */ -#if TCL_MAJOR_VERSION > 8 - size_t selectFirst; /* Character index of first selected + Tcl_Size selectFirst; /* Character index of first selected * character. Writable by items. */ - size_t selectLast; /* Character index of last selected character. + Tcl_Size selectLast; /* Character index of last selected character. * Writable by items. */ -#else - int selectFirst, selectLast; -#endif Tk_Item *anchorItemPtr; /* Item corresponding to "selectAnchor": not * necessarily selItemPtr. Read-only to * items. */ -#if TCL_MAJOR_VERSION > 8 - size_t selectAnchor; /* Character index of fixed end of selection + Tcl_Size selectAnchor; /* Character index of fixed end of selection * (i.e. "select to" operation will use this * as one end of the selection). Writable by * items. */ -#else - int selectAnchor; -#endif Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion * cursor. Read-only to items. */ int insertWidth; /* Total width of insertion cursor. Read-only @@ -1313,21 +1249,21 @@ typedef struct Tk_ImageType Tk_ImageType; #if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 && defined(USE_OLD_IMAGE) typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, char *name, int argc, char **argv, Tk_ImageType *typePtr, Tk_ImageModel model, - ClientData *clientDataPtr); + void **clientDataPtr); #else typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, const char *name, int objc, Tcl_Obj *const objv[], const Tk_ImageType *typePtr, Tk_ImageModel model, - ClientData *clientDataPtr); + void **clientDataPtr); #endif /* USE_OLD_IMAGE */ -typedef ClientData (Tk_ImageGetProc) (Tk_Window tkwin, ClientData clientData); -typedef void (Tk_ImageDisplayProc) (ClientData clientData, Display *display, +typedef void *(Tk_ImageGetProc) (Tk_Window tkwin, void *clientData); +typedef void (Tk_ImageDisplayProc) (void *clientData, Display *display, Drawable drawable, int imageX, int imageY, int width, int height, int drawableX, int drawableY); -typedef void (Tk_ImageFreeProc) (ClientData clientData, Display *display); -typedef void (Tk_ImageDeleteProc) (ClientData clientData); -typedef void (Tk_ImageChangedProc) (ClientData clientData, int x, int y, +typedef void (Tk_ImageFreeProc) (void *clientData, Display *display); +typedef void (Tk_ImageDeleteProc) (void *clientData); +typedef void (Tk_ImageChangedProc) (void *clientData, int x, int y, int width, int height, int imageWidth, int imageHeight); -typedef int (Tk_ImagePostscriptProc) (ClientData clientData, +typedef int (Tk_ImagePostscriptProc) (void *clientData, Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psinfo, int x, int y, int width, int height, int prepass); @@ -1560,16 +1496,16 @@ struct Tk_PhotoImageFormatVersion3 { * declare widget elements. */ -typedef void (Tk_GetElementSizeProc) (ClientData clientData, char *recordPtr, +typedef void (Tk_GetElementSizeProc) (void *clientData, char *recordPtr, const Tk_OptionSpec **optionsPtr, Tk_Window tkwin, int width, int height, int inner, int *widthPtr, int *heightPtr); -typedef void (Tk_GetElementBoxProc) (ClientData clientData, char *recordPtr, +typedef void (Tk_GetElementBoxProc) (void *clientData, char *recordPtr, const Tk_OptionSpec **optionsPtr, Tk_Window tkwin, int x, int y, int width, int height, int inner, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr); -typedef int (Tk_GetElementBorderWidthProc) (ClientData clientData, +typedef int (Tk_GetElementBorderWidthProc) (void *clientData, char *recordPtr, const Tk_OptionSpec **optionsPtr, Tk_Window tkwin); -typedef void (Tk_DrawElementProc) (ClientData clientData, char *recordPtr, +typedef void (Tk_DrawElementProc) (void *clientData, char *recordPtr, const Tk_OptionSpec **optionsPtr, Tk_Window tkwin, Drawable d, int x, int y, int width, int height, int state); @@ -1682,22 +1618,17 @@ EXTERN const char * Tk_PkgInitStubsCheck(Tcl_Interp *interp, *---------------------------------------------------------------------- */ -typedef int (Tk_ErrorProc) (ClientData clientData, XErrorEvent *errEventPtr); -typedef void (Tk_EventProc) (ClientData clientData, XEvent *eventPtr); -typedef int (Tk_GenericProc) (ClientData clientData, XEvent *eventPtr); +typedef int (Tk_ErrorProc) (void *clientData, XErrorEvent *errEventPtr); +typedef void (Tk_EventProc) (void *clientData, XEvent *eventPtr); +typedef int (Tk_GenericProc) (void *clientData, XEvent *eventPtr); typedef int (Tk_ClientMessageProc) (Tk_Window tkwin, XEvent *eventPtr); -typedef int (Tk_GetSelProc) (ClientData clientData, Tcl_Interp *interp, +typedef int (Tk_GetSelProc) (void *clientData, Tcl_Interp *interp, const char *portion); -typedef void (Tk_LostSelProc) (ClientData clientData); -typedef Tk_RestrictAction (Tk_RestrictProc) (ClientData clientData, +typedef void (Tk_LostSelProc) (void *clientData); +typedef Tk_RestrictAction (Tk_RestrictProc) (void *clientData, XEvent *eventPtr); -#if TCL_MAJOR_VERSION > 8 -typedef size_t (Tk_SelectionProc) (ClientData clientData, size_t offset, - char *buffer, size_t maxBytes); -#else -typedef int (Tk_SelectionProc) (ClientData clientData, int offset, - char *buffer, int maxBytes); -#endif +typedef Tcl_Size (Tk_SelectionProc) (void *clientData, Tcl_Size offset, + char *buffer, Tcl_Size maxBytes); /* *---------------------------------------------------------------------- |