summaryrefslogtreecommitdiffstats
path: root/generic/tkMessage.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkMessage.c')
-rw-r--r--generic/tkMessage.c339
1 files changed, 205 insertions, 134 deletions
diff --git a/generic/tkMessage.c b/generic/tkMessage.c
index 6f5d0ce..0dc912c 100644
--- a/generic/tkMessage.c
+++ b/generic/tkMessage.c
@@ -5,22 +5,29 @@
* widget displays a multi-line string in a window according to a
* particular aspect ratio.
*
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 Ajuba Solutions.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Ajuba Solutions.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "default.h"
#include "tkInt.h"
+#include "default.h"
/*
* A data structure of the following type is kept for each message widget
* managed by this file:
*/
+#ifdef TK_NO_DEPRECATED
+# undef DEF_MESSAGE_PADX
+# undef DEF_MESSAGE_PADY
+# define DEF_MESSAGE_PADX NULL
+# define DEF_MESSAGE_PADY NULL
+#endif
+
typedef struct {
Tk_Window tkwin; /* Window that embodies the message. NULL
* means that the window has been destroyed
@@ -39,7 +46,7 @@ typedef struct {
*/
char *string; /* String displayed in message. */
- int numChars; /* Number of characters in string, not
+ Tcl_Size numChars; /* Number of characters in string, not
* including terminating NULL. */
char *textVarName; /* Name of variable (malloc'ed) or NULL.
* If non-NULL, message displays the contents
@@ -47,21 +54,20 @@ typedef struct {
Tk_3DBorder border; /* Structure used to draw 3-D border and
* background. NULL means a border hasn't been
* created yet. */
- int borderWidth; /* Width of border. */
+ Tcl_Obj *borderWidthObj; /* Width of border. */
int relief; /* 3-D effect: TK_RELIEF_RAISED, etc. */
- int highlightWidth; /* Width in pixels of highlight to draw
+ Tcl_Obj *highlightWidthObj; /* Width in pixels of highlight to draw
* around widget when it has the focus.
- * <= 0 means don't draw a highlight. */
+ * 0 means don't draw a highlight. */
XColor *highlightBgColorPtr;
/* Color for drawing traversal highlight
* area when highlight is off. */
XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
Tk_Font tkfont; /* Information about text font, or NULL. */
XColor *fgColorPtr; /* Foreground color in normal mode. */
- Tcl_Obj *padXPtr, *padYPtr; /* Tcl_Obj rep's of padX, padY values. */
- int padX, padY; /* User-requested extra space around text. */
- int width; /* User-requested width, in pixels. 0 means
- * compute width using aspect ratio below. */
+ Tcl_Obj *padXObj, *padYObj; /* Tcl_Obj rep's of padX, padY values. */
+ Tcl_Obj *widthObj; /* User-requested width, in pixels. 0 means
+ * compute width using aspect ratio. */
int aspect; /* Desired aspect ratio for window
* (100*width/height). */
int msgWidth; /* Width in pixels needed to display
@@ -109,57 +115,57 @@ typedef struct {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_MESSAGE_ANCHOR,
- -1, Tk_Offset(Message, anchor), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Message, anchor), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_INT, "-aspect", "aspect", "Aspect", DEF_MESSAGE_ASPECT,
- -1, Tk_Offset(Message, aspect), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Message, aspect), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_MESSAGE_BG_COLOR, -1, Tk_Offset(Message, border), 0,
- DEF_MESSAGE_BG_MONO, 0},
+ DEF_MESSAGE_BG_COLOR, TCL_INDEX_NONE, offsetof(Message, border), 0,
+ DEF_MESSAGE_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL,
- 0, -1, 0, "-borderwidth", 0},
+ 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL,
- 0, -1, 0, "-background", 0},
+ 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_MESSAGE_BORDER_WIDTH, -1,
- Tk_Offset(Message, borderWidth), 0, 0, 0},
+ DEF_MESSAGE_BORDER_WIDTH, offsetof(Message, borderWidthObj),
+ TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_MESSAGE_CURSOR, -1, Tk_Offset(Message, cursor),
- TK_OPTION_NULL_OK, 0, 0},
+ DEF_MESSAGE_CURSOR, TCL_INDEX_NONE, offsetof(Message, cursor),
+ TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL,
- 0, -1, 0, "-foreground", 0},
+ 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_MESSAGE_FONT, -1, Tk_Offset(Message, tkfont), 0, 0, 0},
+ DEF_MESSAGE_FONT, TCL_INDEX_NONE, offsetof(Message, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MESSAGE_FG, -1, Tk_Offset(Message, fgColorPtr), 0, 0, 0},
+ DEF_MESSAGE_FG, TCL_INDEX_NONE, offsetof(Message, fgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_MESSAGE_HIGHLIGHT_BG, -1,
- Tk_Offset(Message, highlightBgColorPtr), 0, 0, 0},
+ "HighlightBackground", DEF_MESSAGE_HIGHLIGHT_BG, TCL_INDEX_NONE,
+ offsetof(Message, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_MESSAGE_HIGHLIGHT, -1, Tk_Offset(Message, highlightColorPtr),
- 0, 0, 0},
+ DEF_MESSAGE_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Message, highlightColorPtr),
+ 0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_MESSAGE_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Message, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_MESSAGE_HIGHLIGHT_WIDTH, offsetof(Message, highlightWidthObj),
+ TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_MESSAGE_JUSTIFY, -1, Tk_Offset(Message, justify), 0, 0, 0},
+ DEF_MESSAGE_JUSTIFY, TCL_INDEX_NONE, offsetof(Message, justify), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_MESSAGE_PADX, Tk_Offset(Message, padXPtr),
- Tk_Offset(Message, padX), 0, 0, 0},
+ DEF_MESSAGE_PADX, offsetof(Message, padXObj),
+ TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_MESSAGE_PADY, Tk_Offset(Message, padYPtr),
- Tk_Offset(Message, padY), 0, 0, 0},
+ DEF_MESSAGE_PADY, offsetof(Message, padYObj),
+ TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_MESSAGE_RELIEF, -1, Tk_Offset(Message, relief), 0, 0, 0},
+ DEF_MESSAGE_RELIEF, TCL_INDEX_NONE, offsetof(Message, relief), 0, 0, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_MESSAGE_TAKE_FOCUS, -1, Tk_Offset(Message, takeFocus),
+ DEF_MESSAGE_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Message, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_MESSAGE_TEXT, -1, Tk_Offset(Message, string), 0, 0, 0},
+ DEF_MESSAGE_TEXT, TCL_INDEX_NONE, offsetof(Message, string), 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_MESSAGE_TEXT_VARIABLE, -1, Tk_Offset(Message, textVarName),
+ DEF_MESSAGE_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Message, textVarName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_MESSAGE_WIDTH, -1, Tk_Offset(Message, width), 0, 0 ,0},
+ DEF_MESSAGE_WIDTH, offsetof(Message, widthObj), TCL_INDEX_NONE, 0, 0 ,0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -167,21 +173,19 @@ static const Tk_OptionSpec optionSpecs[] = {
* Forward declarations for functions defined later in this file:
*/
-static void MessageCmdDeletedProc(ClientData clientData);
-static void MessageEventProc(ClientData clientData,
+static void MessageCmdDeletedProc(void *clientData);
+static void MessageEventProc(void *clientData,
XEvent *eventPtr);
-static char * MessageTextVarProc(ClientData clientData,
+static char * MessageTextVarProc(void *clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
-static int MessageWidgetObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-static void MessageWorldChanged(ClientData instanceData);
+static Tcl_ObjCmdProc MessageWidgetObjCmd;
+static void MessageWorldChanged(void *instanceData);
static void ComputeMessageGeometry(Message *msgPtr);
static int ConfigureMessage(Tcl_Interp *interp, Message *msgPtr,
int objc, Tcl_Obj *const objv[], int flags);
-static void DestroyMessage(char *memPtr);
-static void DisplayMessage(ClientData clientData);
+static void DestroyMessage(void *memPtr);
+static void DisplayMessage(void *clientData);
/*
* The structure below defines message class behavior by means of functions
@@ -214,7 +218,7 @@ static const Tk_ClassProcs messageClass = {
int
Tk_MessageObjCmd(
- ClientData clientData, /* NULL. */
+ TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -241,8 +245,8 @@ Tk_MessageObjCmd(
optionTable = Tk_CreateOptionTable(interp, optionSpecs);
- msgPtr = ckalloc(sizeof(Message));
- memset(msgPtr, 0, (size_t) sizeof(Message));
+ msgPtr = (Message *)ckalloc(sizeof(Message));
+ memset(msgPtr, 0, sizeof(Message));
/*
* Set values for those fields that don't take a 0 or NULL value.
@@ -267,7 +271,7 @@ Tk_MessageObjCmd(
Tk_CreateEventHandler(msgPtr->tkwin,
ExposureMask|StructureNotifyMask|FocusChangeMask,
MessageEventProc, msgPtr);
- if (Tk_InitOptions(interp, (char *)msgPtr, optionTable, tkwin) != TCL_OK) {
+ if (Tk_InitOptions(interp, msgPtr, optionTable, tkwin) != TCL_OK) {
Tk_DestroyWindow(msgPtr->tkwin);
return TCL_ERROR;
}
@@ -277,7 +281,7 @@ Tk_MessageObjCmd(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(msgPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(msgPtr->tkwin));
return TCL_OK;
}
@@ -301,12 +305,12 @@ Tk_MessageObjCmd(
static int
MessageWidgetObjCmd(
- ClientData clientData, /* Information about message widget. */
+ void *clientData, /* Information about message widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
static const char *const optionStrings[] = { "cget", "configure", NULL };
enum options { MESSAGE_CGET, MESSAGE_CONFIGURE };
int index;
@@ -331,7 +335,7 @@ MessageWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "option");
result = TCL_ERROR;
} else {
- objPtr = Tk_GetOptionValue(interp, (char *) msgPtr,
+ objPtr = Tk_GetOptionValue(interp, msgPtr,
msgPtr->optionTable, objv[2], msgPtr->tkwin);
if (objPtr == NULL) {
result = TCL_ERROR;
@@ -343,7 +347,7 @@ MessageWidgetObjCmd(
break;
case MESSAGE_CONFIGURE:
if (objc <= 3) {
- objPtr = Tk_GetOptionInfo(interp, (char *) msgPtr,
+ objPtr = Tk_GetOptionInfo(interp, msgPtr,
msgPtr->optionTable, (objc == 3) ? objv[2] : NULL,
msgPtr->tkwin);
if (objPtr == NULL) {
@@ -382,7 +386,7 @@ MessageWidgetObjCmd(
static void
DestroyMessage(
- char *memPtr) /* Info about message widget. */
+ void *memPtr) /* Info about message widget. */
{
Message *msgPtr = (Message *) memPtr;
@@ -409,7 +413,7 @@ DestroyMessage(
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
MessageTextVarProc, msgPtr);
}
- Tk_FreeConfigOptions((char *) msgPtr, msgPtr->optionTable, msgPtr->tkwin);
+ Tk_FreeConfigOptions(msgPtr, msgPtr->optionTable, msgPtr->tkwin);
msgPtr->tkwin = NULL;
ckfree(msgPtr);
}
@@ -441,9 +445,10 @@ ConfigureMessage(
* already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[], /* Arguments. */
- int flags) /* Flags to pass to Tk_ConfigureWidget. */
+ TCL_UNUSED(int)) /* Flags to pass to Tk_ConfigureWidget. */
{
Tk_SavedOptions savedOptions;
+ int width, borderWidth, highlightWidth, padX, padY;
/*
* Eliminate any existing trace on a variable monitored by the message.
@@ -455,7 +460,7 @@ ConfigureMessage(
MessageTextVarProc, msgPtr);
}
- if (Tk_SetOptions(interp, (char *) msgPtr, msgPtr->optionTable, objc, objv,
+ if (Tk_SetOptions(interp, msgPtr, msgPtr->optionTable, objc, objv,
msgPtr->tkwin, &savedOptions, NULL) != TCL_OK) {
Tk_RestoreSavedOptions(&savedOptions);
return TCL_ERROR;
@@ -478,7 +483,7 @@ ConfigureMessage(
if (msgPtr->string != NULL) {
ckfree(msgPtr->string);
}
- msgPtr->string = strcpy(ckalloc(strlen(value) + 1), value);
+ msgPtr->string = strcpy((char *)ckalloc(strlen(value) + 1), value);
}
Tcl_TraceVar2(interp, msgPtr->textVarName, NULL,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
@@ -491,10 +496,55 @@ ConfigureMessage(
* be specified to Tk_ConfigureWidget.
*/
- msgPtr->numChars = Tcl_NumUtfChars(msgPtr->string, -1);
+ msgPtr->numChars = TkNumUtfChars(msgPtr->string, TCL_INDEX_NONE);
- if (msgPtr->highlightWidth < 0) {
- msgPtr->highlightWidth = 0;
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->widthObj, &width);
+ if (width < 0) {
+ if (msgPtr->widthObj) {
+ Tcl_DecrRefCount(msgPtr->widthObj);
+ }
+ msgPtr->widthObj = Tcl_NewIntObj(0);
+ Tcl_IncrRefCount(msgPtr->widthObj);
+ }
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &borderWidth);
+ if (borderWidth < 0) {
+ if (msgPtr->borderWidthObj) {
+ Tcl_DecrRefCount(msgPtr->borderWidthObj);
+ }
+ msgPtr->borderWidthObj = Tcl_NewIntObj(0);
+ Tcl_IncrRefCount(msgPtr->borderWidthObj);
+ }
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth);
+ if (highlightWidth < 0) {
+ if (msgPtr->highlightWidthObj) {
+ Tcl_DecrRefCount(msgPtr->highlightWidthObj);
+ }
+ msgPtr->highlightWidthObj = Tcl_NewIntObj(0);
+ Tcl_IncrRefCount(msgPtr->highlightWidthObj);
+ }
+ if (!msgPtr->padXObj) {
+ msgPtr->padXObj = Tcl_NewIntObj(-1);
+ Tcl_IncrRefCount(msgPtr->padXObj);
+ }
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padXObj, &padX);
+ if (padX < 0) {
+ if (strcmp(Tcl_GetString(msgPtr->padXObj), "-1")) {
+ Tcl_DecrRefCount(msgPtr->padXObj);
+ msgPtr->padXObj = Tcl_NewIntObj(-1);
+ Tcl_IncrRefCount(msgPtr->padXObj);
+ }
+ }
+ if (!msgPtr->padYObj) {
+ msgPtr->padYObj = Tcl_NewIntObj(-1);
+ Tcl_IncrRefCount(msgPtr->padYObj);
+ }
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padYObj, &padY);
+ if (padY < 0) {
+ if (strcmp(Tcl_GetString(msgPtr->padYObj), "-1")) {
+ Tcl_DecrRefCount(msgPtr->padYObj);
+ msgPtr->padYObj = Tcl_NewIntObj(-1);
+ Tcl_IncrRefCount(msgPtr->padYObj);
+ }
}
Tk_FreeSavedOptions(&savedOptions);
@@ -522,12 +572,11 @@ ConfigureMessage(
static void
MessageWorldChanged(
- ClientData instanceData) /* Information about widget. */
+ void *instanceData) /* Information about widget. */
{
XGCValues gcValues;
GC gc = NULL;
- Tk_FontMetrics fm;
- Message *msgPtr = instanceData;
+ Message *msgPtr = (Message *)instanceData;
if (msgPtr->border != NULL) {
Tk_SetBackgroundFromBorder(msgPtr->tkwin, msgPtr->border);
@@ -541,14 +590,6 @@ MessageWorldChanged(
}
msgPtr->textGC = gc;
- Tk_GetFontMetrics(msgPtr->tkfont, &fm);
- if (msgPtr->padX < 0) {
- msgPtr->padX = fm.ascent / 2;
- }
- if (msgPtr->padY == -1) {
- msgPtr->padY = fm.ascent / 4;
- }
-
/*
* Recompute the desired geometry for the window, and arrange for the
* window to be redisplayed.
@@ -587,10 +628,24 @@ ComputeMessageGeometry(
int width, inc, height;
int thisWidth, thisHeight, maxWidth;
int aspect, lowerBound, upperBound, inset;
+ int borderWidth, highlightWidth, padX, padY;
+ Tk_FontMetrics fm;
Tk_FreeTextLayout(msgPtr->textLayout);
- inset = msgPtr->borderWidth + msgPtr->highlightWidth;
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &borderWidth);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padXObj, &padX);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padYObj, &padY);
+ Tk_GetFontMetrics(msgPtr->tkfont, &fm);
+ if (padX < 0) {
+ padX = fm.ascent / 2;
+ }
+ if (padY < 0) {
+ padY = fm.ascent / 4;
+ }
+
+ inset = borderWidth + highlightWidth;
/*
* Compute acceptable bounds for the final aspect ratio.
@@ -611,8 +666,8 @@ ComputeMessageGeometry(
* explicit width then just use that.
*/
- if (msgPtr->width > 0) {
- width = msgPtr->width;
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->widthObj, &width);
+ if (width > 0) {
inc = 0;
} else {
width = WidthOfScreen(Tk_Screen(msgPtr->tkwin))/2;
@@ -623,8 +678,8 @@ ComputeMessageGeometry(
msgPtr->textLayout = Tk_ComputeTextLayout(msgPtr->tkfont,
msgPtr->string, msgPtr->numChars, width, msgPtr->justify,
0, &thisWidth, &thisHeight);
- maxWidth = thisWidth + 2 * (inset + msgPtr->padX);
- height = thisHeight + 2 * (inset + msgPtr->padY);
+ maxWidth = thisWidth + 2 * (inset + padX);
+ height = thisHeight + 2 * (inset + padY);
if (inc <= 2) {
break;
@@ -664,27 +719,41 @@ ComputeMessageGeometry(
static void
DisplayMessage(
- ClientData clientData) /* Information about window. */
+ void *clientData) /* Information about window. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
Tk_Window tkwin = msgPtr->tkwin;
int x, y;
- int borderWidth = msgPtr->highlightWidth;
+ int width, borderWidth, highlightWidth, padX, padY;
+ Tk_FontMetrics fm;
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &borderWidth);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padXObj, &padX);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padYObj, &padY);
+ Tk_GetFontMetrics(msgPtr->tkfont, &fm);
+ if (padX < 0) {
+ padX = fm.ascent / 2;
+ }
+ if (padY < 0) {
+ padY = fm.ascent / 4;
+ }
+
+ width = highlightWidth;
msgPtr->flags &= ~REDRAW_PENDING;
if ((msgPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
return;
}
if (msgPtr->border != NULL) {
- borderWidth += msgPtr->borderWidth;
+ width += borderWidth;
}
if (msgPtr->relief == TK_RELIEF_FLAT) {
- borderWidth = msgPtr->highlightWidth;
+ width = highlightWidth;
}
Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), msgPtr->border,
- borderWidth, borderWidth,
- Tk_Width(tkwin) - 2 * borderWidth,
- Tk_Height(tkwin) - 2 * borderWidth,
+ width, width,
+ Tk_Width(tkwin) - 2 * width,
+ Tk_Height(tkwin) - 2 * width,
0, TK_RELIEF_FLAT);
/*
@@ -692,28 +761,28 @@ DisplayMessage(
* anchor option.
*/
- TkComputeAnchor(msgPtr->anchor, tkwin, msgPtr->padX, msgPtr->padY,
+ TkComputeAnchor(msgPtr->anchor, tkwin, padX, padY,
msgPtr->msgWidth, msgPtr->msgHeight, &x, &y);
Tk_DrawTextLayout(Tk_Display(tkwin), Tk_WindowId(tkwin), msgPtr->textGC,
msgPtr->textLayout, x, y, 0, -1);
- if (borderWidth > msgPtr->highlightWidth) {
+ if (width > highlightWidth) {
Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), msgPtr->border,
- msgPtr->highlightWidth, msgPtr->highlightWidth,
- Tk_Width(tkwin) - 2*msgPtr->highlightWidth,
- Tk_Height(tkwin) - 2*msgPtr->highlightWidth,
- msgPtr->borderWidth, msgPtr->relief);
+ highlightWidth, highlightWidth,
+ Tk_Width(tkwin) - 2 * highlightWidth,
+ Tk_Height(tkwin) - 2 * highlightWidth,
+ borderWidth, msgPtr->relief);
}
- if (msgPtr->highlightWidth != 0) {
+ if (highlightWidth > 0) {
GC fgGC, bgGC;
bgGC = Tk_GCForColor(msgPtr->highlightBgColorPtr, Tk_WindowId(tkwin));
if (msgPtr->flags & GOT_FOCUS) {
fgGC = Tk_GCForColor(msgPtr->highlightColorPtr,Tk_WindowId(tkwin));
- TkpDrawHighlightBorder(tkwin, fgGC, bgGC, msgPtr->highlightWidth,
+ Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, highlightWidth,
Tk_WindowId(tkwin));
} else {
- TkpDrawHighlightBorder(tkwin, bgGC, bgGC, msgPtr->highlightWidth,
+ Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, highlightWidth,
Tk_WindowId(tkwin));
}
}
@@ -739,10 +808,11 @@ DisplayMessage(
static void
MessageEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
+ int highlightWidth;
if (((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0))
|| (eventPtr->type == ConfigureNotify)) {
@@ -752,14 +822,16 @@ MessageEventProc(
} else if (eventPtr->type == FocusIn) {
if (eventPtr->xfocus.detail != NotifyInferior) {
msgPtr->flags |= GOT_FOCUS;
- if (msgPtr->highlightWidth > 0) {
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth);
+ if (highlightWidth > 0) {
goto redraw;
}
}
} else if (eventPtr->type == FocusOut) {
if (eventPtr->xfocus.detail != NotifyInferior) {
msgPtr->flags &= ~GOT_FOCUS;
- if (msgPtr->highlightWidth > 0) {
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth);
+ if (highlightWidth > 0) {
goto redraw;
}
}
@@ -793,9 +865,9 @@ MessageEventProc(
static void
MessageCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
/*
* This function could be invoked either because the window was destroyed
@@ -826,16 +898,15 @@ MessageCmdDeletedProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
MessageTextVarProc(
- ClientData clientData, /* Information about message. */
+ void *clientData, /* Information about message. */
Tcl_Interp *interp, /* Interpreter containing variable. */
- const char *name1, /* Name of variable. */
- const char *name2, /* Second part of variable name. */
+ TCL_UNUSED(const char *), /* Name of variable. */
+ TCL_UNUSED(const char *), /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
const char *value;
/*
@@ -844,27 +915,27 @@ MessageTextVarProc(
*/
if (flags & TCL_TRACE_UNSETS) {
- if (!Tcl_InterpDeleted(interp) && msgPtr->textVarName) {
- ClientData probe = NULL;
-
- do {
- probe = Tcl_VarTraceInfo(interp,
- msgPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MessageTextVarProc, probe);
- if (probe == (ClientData)msgPtr) {
- break;
- }
- } while (probe);
- if (probe) {
- /*
- * We were able to fetch the unset trace for our
- * textVarName, which means it is not unset and not
- * the cause of this unset trace. Instead some outdated
- * former variable must be, and we should ignore it.
- */
- return NULL;
- }
+ if (!Tcl_InterpDeleted(interp) && msgPtr->textVarName) {
+ void *probe = NULL;
+
+ do {
+ probe = Tcl_VarTraceInfo(interp,
+ msgPtr->textVarName,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ MessageTextVarProc, probe);
+ if (probe == (void *)msgPtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * textVarName, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former variable must be, and we should ignore it.
+ */
+ return NULL;
+ }
Tcl_SetVar2(interp, msgPtr->textVarName, NULL, msgPtr->string,
TCL_GLOBAL_ONLY);
Tcl_TraceVar2(interp, msgPtr->textVarName, NULL,
@@ -881,8 +952,8 @@ MessageTextVarProc(
if (msgPtr->string != NULL) {
ckfree(msgPtr->string);
}
- msgPtr->numChars = Tcl_NumUtfChars(value, -1);
- msgPtr->string = ckalloc(strlen(value) + 1);
+ msgPtr->numChars = TkNumUtfChars(value, TCL_INDEX_NONE);
+ msgPtr->string = (char *)ckalloc(strlen(value) + 1);
strcpy(msgPtr->string, value);
ComputeMessageGeometry(msgPtr);