summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-01-19 12:28:15 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-01-19 12:28:15 (GMT)
commitf17310ab6d637ba1c6aab9e26c2790e5a7c91775 (patch)
treeb192f371417202ca79f88ff35c884b34b1cc20af /generic
parent7d012900cd3eee5f14e3ebd061726ffa3510550f (diff)
downloadtk-f17310ab6d637ba1c6aab9e26c2790e5a7c91775.zip
tk-f17310ab6d637ba1c6aab9e26c2790e5a7c91775.tar.gz
tk-f17310ab6d637ba1c6aab9e26c2790e5a7c91775.tar.bz2
Improve "-align"
Diffstat (limited to 'generic')
-rw-r--r--generic/tk.h9
-rw-r--r--generic/tkText.h8
-rw-r--r--generic/tkTextImage.c18
-rw-r--r--generic/tkTextWind.c18
4 files changed, 25 insertions, 28 deletions
diff --git a/generic/tk.h b/generic/tk.h
index 6a5df0d..b8023be 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -1552,8 +1552,7 @@ typedef struct Tk_ElementSpec {
*----------------------------------------------------------------------
*
* The definitions below provide backward compatibility for functions and
- * types related to event handling that used to be in Tk but have moved to
- * Tcl.
+ * types that used to be in Tk but have moved to Tcl.
*
*----------------------------------------------------------------------
*/
@@ -1592,6 +1591,10 @@ typedef struct Tk_ElementSpec {
#define Tk_FreeProc Tcl_FreeProc
#define Tk_Preserve Tcl_Preserve
#define Tk_Release Tcl_Release
+
+/* Related to USE_OLD_IMAGE: */
+
+#define Tk_InitImageArgs(interp, argc, argv) /**/
#endif
/* Removed Tk_Main, use macro instead */
@@ -1611,8 +1614,6 @@ EXTERN const char * Tk_PkgInitStubsCheck(Tcl_Interp *interp,
#define Tk_InitStubs(interp, version, exact) \
Tk_PkgInitStubsCheck(interp, version, exact)
#endif /* USE_TK_STUBS */
-
-#define Tk_InitImageArgs(interp, argc, argv) /**/
/*
*----------------------------------------------------------------------
diff --git a/generic/tkText.h b/generic/tkText.h
index 2f663d2..b16ada9 100644
--- a/generic/tkText.h
+++ b/generic/tkText.h
@@ -99,6 +99,10 @@ typedef struct TkTextEmbWindowClient {
struct TkTextEmbWindowClient *next;
} TkTextEmbWindowClient;
+typedef enum {
+ TK_ALIGN_BASELINE, TK_ALIGN_BOTTOM, TK_ALIGN_CENTER, TK_ALIGN_TOP
+} TkAlignMode;
+
typedef struct TkTextEmbWindow {
struct TkSharedText *sharedTextPtr;
/* Information about the shared portion of the
@@ -112,7 +116,7 @@ typedef struct TkTextEmbWindow {
* window. */
char *create; /* Script to create window on-demand. NULL
* means no such script. Malloc-ed. */
- int align; /* How to align window in vertical space. See
+ TkAlignMode align; /* How to align window in vertical space. See
* definitions in tkTextWind.c. */
int padX, padY; /* Padding to leave around each side of
* window, in pixels. */
@@ -144,7 +148,7 @@ typedef struct TkTextEmbImage {
* the image. */
Tk_Image image; /* Image for this segment. NULL means that the
* image hasn't been created yet. */
- int align; /* How to align image in vertical space. See
+ TkAlignMode align; /* How to align image in vertical space. See
* definitions in tkTextImage.c. */
int padX, padY; /* Padding to leave around each side of image,
* in pixels. */
diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c
index e759584..2d2498b 100644
--- a/generic/tkTextImage.c
+++ b/generic/tkTextImage.c
@@ -77,10 +77,6 @@ static const char *const alignStrings[] = {
"baseline", "bottom", "center", "top", NULL
};
-typedef enum {
- ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_TOP
-} alignMode;
-
/*
* Information used for parsing image configuration options:
*/
@@ -88,7 +84,7 @@ typedef enum {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-align", NULL, NULL,
"center", TCL_INDEX_NONE, offsetof(TkTextEmbImage, align),
- 0, alignStrings, 0},
+ TK_OPTION_ENUM_VAR, alignStrings, 0},
{TK_OPTION_PIXELS, "-padx", NULL, NULL,
"0", TCL_INDEX_NONE, offsetof(TkTextEmbImage, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", NULL, NULL,
@@ -255,7 +251,7 @@ TkTextImageCmd(
eiPtr->body.ei.imageString = NULL;
eiPtr->body.ei.name = NULL;
eiPtr->body.ei.image = NULL;
- eiPtr->body.ei.align = ALIGN_CENTER;
+ eiPtr->body.ei.align = TK_ALIGN_CENTER;
eiPtr->body.ei.padX = eiPtr->body.ei.padY = 0;
eiPtr->body.ei.chunkCount = 0;
eiPtr->body.ei.optionTable = Tk_CreateOptionTable(interp, optionSpecs);
@@ -566,7 +562,7 @@ EmbImageLayoutProc(
chunkPtr->measureProc = NULL;
chunkPtr->bboxProc = EmbImageBboxProc;
chunkPtr->numBytes = 1;
- if (eiPtr->body.ei.align == ALIGN_BASELINE) {
+ if (eiPtr->body.ei.align == TK_ALIGN_BASELINE) {
chunkPtr->minAscent = height - eiPtr->body.ei.padY;
chunkPtr->minDescent = eiPtr->body.ei.padY;
chunkPtr->minHeight = 0;
@@ -728,16 +724,16 @@ EmbImageBboxProc(
*xPtr = chunkPtr->x + eiPtr->body.ei.padX;
switch (eiPtr->body.ei.align) {
- case ALIGN_BOTTOM:
+ case TK_ALIGN_BOTTOM:
*yPtr = y + (lineHeight - *heightPtr - eiPtr->body.ei.padY);
break;
- case ALIGN_CENTER:
+ case TK_ALIGN_CENTER:
*yPtr = y + (lineHeight - *heightPtr)/2;
break;
- case ALIGN_TOP:
+ case TK_ALIGN_TOP:
*yPtr = y + eiPtr->body.ei.padY;
break;
- case ALIGN_BASELINE:
+ case TK_ALIGN_BASELINE:
*yPtr = y + (baseline - *heightPtr);
break;
}
diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c
index d283c27..f8ec9f5 100644
--- a/generic/tkTextWind.c
+++ b/generic/tkTextWind.c
@@ -89,10 +89,6 @@ static const char *const alignStrings[] = {
"baseline", "bottom", "center", "top", NULL
};
-typedef enum {
- ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_TOP
-} alignMode;
-
/*
* Information used for parsing window configuration options:
*/
@@ -295,7 +291,7 @@ TkTextWindowCmd(
ewPtr->body.ew.linePtr = NULL;
ewPtr->body.ew.tkwin = NULL;
ewPtr->body.ew.create = NULL;
- ewPtr->body.ew.align = ALIGN_CENTER;
+ ewPtr->body.ew.align = TK_ALIGN_CENTER;
ewPtr->body.ew.padX = ewPtr->body.ew.padY = 0;
ewPtr->body.ew.stretch = 0;
ewPtr->body.ew.optionTable = Tk_CreateOptionTable(interp, optionSpecs);
@@ -1009,7 +1005,7 @@ EmbWinLayoutProc(
chunkPtr->measureProc = NULL;
chunkPtr->bboxProc = EmbWinBboxProc;
chunkPtr->numBytes = 1;
- if (ewPtr->body.ew.align == ALIGN_BASELINE) {
+ if (ewPtr->body.ew.align == TK_ALIGN_BASELINE) {
chunkPtr->minAscent = height - ewPtr->body.ew.padY;
chunkPtr->minDescent = ewPtr->body.ew.padY;
chunkPtr->minHeight = 0;
@@ -1257,23 +1253,23 @@ EmbWinBboxProc(
}
*xPtr = chunkPtr->x + ewPtr->body.ew.padX;
if (ewPtr->body.ew.stretch) {
- if (ewPtr->body.ew.align == ALIGN_BASELINE) {
+ if (ewPtr->body.ew.align == TK_ALIGN_BASELINE) {
*heightPtr = baseline - ewPtr->body.ew.padY;
} else {
*heightPtr = lineHeight - 2*ewPtr->body.ew.padY;
}
}
switch (ewPtr->body.ew.align) {
- case ALIGN_BOTTOM:
+ case TK_ALIGN_BOTTOM:
*yPtr = y + (lineHeight - *heightPtr - ewPtr->body.ew.padY);
break;
- case ALIGN_CENTER:
+ case TK_ALIGN_CENTER:
*yPtr = y + (lineHeight - *heightPtr)/2;
break;
- case ALIGN_TOP:
+ case TK_ALIGN_TOP:
*yPtr = y + ewPtr->body.ew.padY;
break;
- case ALIGN_BASELINE:
+ case TK_ALIGN_BASELINE:
*yPtr = y + (baseline - *heightPtr);
break;
}