summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorhobbs <hobbs>1999-12-16 21:57:35 (GMT)
committerhobbs <hobbs>1999-12-16 21:57:35 (GMT)
commitd3ed5663cab03782de9a8c9459ebdf859ca8bbe5 (patch)
treea359295061e8e63458411176f65e6bc6517f9dec /generic
parent806f3e8e5f86a8eec2a7b052e173b98fc6ecf928 (diff)
downloadtk-d3ed5663cab03782de9a8c9459ebdf859ca8bbe5.zip
tk-d3ed5663cab03782de9a8c9459ebdf859ca8bbe5.tar.gz
tk-d3ed5663cab03782de9a8c9459ebdf859ca8bbe5.tar.bz2
* generic/tkCmds.c:
* generic/tkEvent.c: * generic/tkWindow.c: * generic/tkInt.h: add 'tk useinputmethods ?-display win? ?bool?' call to provide support for disabling/enabling the use of XIM on X. This was previously all done at compile time, and always on. Now it * generic/tkCanvUtil.c: fixed bug in Tk_CanvasPsOutline that freed mem it shouldn't. * generic/tkFont.c: added "bitstream cyberbit" (popular Windows CJK font) to list of font fallbacks. (kenny) [Bug: 2407]
Diffstat (limited to 'generic')
-rw-r--r--generic/tkCanvUtil.c117
-rw-r--r--generic/tkCmds.c47
-rw-r--r--generic/tkEvent.c19
-rw-r--r--generic/tkFont.c3
-rw-r--r--generic/tkInt.h3
-rw-r--r--generic/tkWindow.c3
6 files changed, 117 insertions, 75 deletions
diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c
index 3c79861..5ec5eb7 100644
--- a/generic/tkCanvUtil.c
+++ b/generic/tkCanvUtil.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkCanvUtil.c,v 1.4 1999/12/14 06:52:26 hobbs Exp $
+ * RCS: @(#) $Id: tkCanvUtil.c,v 1.5 1999/12/16 21:57:35 hobbs Exp $
*/
#include "tkInt.h"
@@ -685,7 +685,7 @@ TkSmoothParseProc(clientData, interp, tkwin, value, widgRec, offset)
size_t length;
SmoothAssocData *methods;
- if(value == NULL || *value == 0) {
+ if (value == NULL || *value == 0) {
*smoothPtr = (Tk_SmoothMethod *) NULL;
return TCL_OK;
}
@@ -993,7 +993,7 @@ int Tk_ConfigOutlineGC(gcValues, canvas, item, outline)
dash = &(outline->dash);
color = outline->color;
stipple = outline->stipple;
- if(state == TK_STATE_NULL) {
+ if (state == TK_STATE_NULL) {
state = ((TkCanvas *)canvas)->canvas_state;
}
if (((TkCanvas *)canvas)->currentItemPtr == item) {
@@ -1094,33 +1094,33 @@ Tk_ChangeOutlineGC(canvas, item, outline)
dash = &(outline->dash);
color = outline->color;
stipple = outline->stipple;
- if(state == TK_STATE_NULL) {
+ if (state == TK_STATE_NULL) {
state = ((TkCanvas *)canvas)->canvas_state;
}
if (((TkCanvas *)canvas)->currentItemPtr == item) {
- if (outline->activeWidth>width) {
+ if (outline->activeWidth > width) {
width = outline->activeWidth;
}
if (outline->activeDash.number != 0) {
dash = &(outline->activeDash);
}
- if (outline->activeColor!=NULL) {
+ if (outline->activeColor != NULL) {
color = outline->activeColor;
}
- if (outline->activeStipple!=None) {
+ if (outline->activeStipple != None) {
stipple = outline->activeStipple;
}
- } else if (state==TK_STATE_DISABLED) {
- if (outline->disabledWidth>width) {
+ } else if (state == TK_STATE_DISABLED) {
+ if (outline->disabledWidth > width) {
width = outline->disabledWidth;
}
if (outline->disabledDash.number != 0) {
dash = &(outline->disabledDash);
}
- if (outline->disabledColor!=NULL) {
+ if (outline->disabledColor != NULL) {
color = outline->disabledColor;
}
- if (outline->disabledStipple!=None) {
+ if (outline->disabledStipple != None) {
stipple = outline->disabledStipple;
}
}
@@ -1210,7 +1210,7 @@ Tk_ResetOutlineGC(canvas, item, outline)
dash = &(outline->dash);
color = outline->color;
stipple = outline->stipple;
- if(state == TK_STATE_NULL) {
+ if (state == TK_STATE_NULL) {
state = ((TkCanvas *)canvas)->canvas_state;
}
if (((TkCanvas *)canvas)->currentItemPtr == item) {
@@ -1254,9 +1254,10 @@ Tk_ResetOutlineGC(canvas, item, outline)
} else {
dashList = 4;
}
- XSetDashes(((TkCanvas *)canvas)->display, outline->gc, outline->offset, &dashList , 1);
+ XSetDashes(((TkCanvas *)canvas)->display, outline->gc,
+ outline->offset, &dashList , 1);
}
- if (stipple!=None) {
+ if (stipple != None) {
XSetTSOrigin(((TkCanvas *)canvas)->display, outline->gc, 0, 0);
return 1;
}
@@ -1290,9 +1291,9 @@ Tk_CanvasPsOutline(canvas, item, outline)
char string[41];
char pattern[11];
int i;
- char *p;
- char *s = string;
- char *l = pattern;
+ char *ptr;
+ char *str = string;
+ char *lptr = pattern;
Tcl_Interp *interp = ((TkCanvas *)canvas)->interp;
double width;
Tk_Dash *dash;
@@ -1304,33 +1305,33 @@ Tk_CanvasPsOutline(canvas, item, outline)
dash = &(outline->dash);
color = outline->color;
stipple = outline->stipple;
- if(state == TK_STATE_NULL) {
+ if (state == TK_STATE_NULL) {
state = ((TkCanvas *)canvas)->canvas_state;
}
if (((TkCanvas *)canvas)->currentItemPtr == item) {
- if (outline->activeWidth>width) {
+ if (outline->activeWidth > width) {
width = outline->activeWidth;
}
- if (outline->activeDash.number>0) {
+ if (outline->activeDash.number > 0) {
dash = &(outline->activeDash);
}
- if (outline->activeColor!=NULL) {
+ if (outline->activeColor != NULL) {
color = outline->activeColor;
}
- if (outline->activeStipple!=None) {
+ if (outline->activeStipple != None) {
stipple = outline->activeStipple;
}
- } else if (state==TK_STATE_DISABLED) {
- if (outline->disabledWidth>0) {
+ } else if (state == TK_STATE_DISABLED) {
+ if (outline->disabledWidth > 0) {
width = outline->disabledWidth;
}
- if (outline->disabledDash.number>0) {
+ if (outline->disabledDash.number > 0) {
dash = &(outline->disabledDash);
}
- if (outline->disabledColor!=NULL) {
+ if (outline->disabledColor != NULL) {
color = outline->disabledColor;
}
- if (outline->disabledStipple!=None) {
+ if (outline->disabledStipple != None) {
stipple = outline->disabledStipple;
}
}
@@ -1338,54 +1339,56 @@ Tk_CanvasPsOutline(canvas, item, outline)
Tcl_AppendResult(interp, string, (char *) NULL);
if (dash->number > 10) {
- s = (char *)ckalloc(1 + 4*(unsigned int)dash->number);
- } else if (dash->number<-5) {
- s = (char *)ckalloc(1 - 8*(unsigned int)dash->number);
- l = (char *)ckalloc(1 - 2*(unsigned int)dash->number);
+ str = (char *)ckalloc((unsigned int) (1 + 4*dash->number));
+ } else if (dash->number < -5) {
+ str = (char *)ckalloc((unsigned int) (1 - 8*dash->number));
+ lptr = (char *)ckalloc((unsigned int) (1 - 2*dash->number));
}
- p = (char *) ((ABS(dash->number) > sizeof(char *)) ) ?
+ ptr = (char *) ((ABS(dash->number) > sizeof(char *)) ) ?
dash->pattern.pt : dash->pattern.array;
if (dash->number > 0) {
- sprintf(s,"[%d",*p++ & 0xff);
- i=dash->number-1;
- while(i--) {
- sprintf(s+strlen(s)," %d",*p++ & 0xff);
+ char *ptr0 = ptr;
+ sprintf(str, "[%d", *ptr++ & 0xff);
+ i = dash->number-1;
+ while (i--) {
+ sprintf(str+strlen(str), " %d", *ptr++ & 0xff);
}
- Tcl_AppendResult(interp,s,(char *)NULL);
+ Tcl_AppendResult(interp, str, (char *)NULL);
if (dash->number&1) {
- Tcl_AppendResult(interp," ",s+1,(char *)NULL);
+ Tcl_AppendResult(interp, " ", str+1, (char *)NULL);
}
- sprintf(s,"] %d setdash\n",outline->offset);
- Tcl_AppendResult(interp,s,(char *)NULL);
+ sprintf(str, "] %d setdash\n", outline->offset);
+ Tcl_AppendResult(interp, str, (char *)NULL);
+ ptr = ptr0;
} else if (dash->number < 0) {
- if ((i = DashConvert(l ,p, -dash->number, width)) != 0) {
- sprintf(s,"[%d",*l++ & 0xff);
- while(--i) {
- sprintf(s+strlen(s)," %d",*l++ & 0xff);
+ if ((i = DashConvert(lptr, ptr, -dash->number, width)) != 0) {
+ char *lptr0 = lptr;
+ sprintf(str, "[%d", *lptr++ & 0xff);
+ while (--i) {
+ sprintf(str+strlen(str), " %d", *lptr++ & 0xff);
}
- Tcl_AppendResult(interp,s,(char *)NULL);
- sprintf(s,"] %d setdash\n",outline->offset);
- Tcl_AppendResult(interp,s,(char *)NULL);
+ Tcl_AppendResult(interp, str, (char *)NULL);
+ sprintf(str, "] %d setdash\n", outline->offset);
+ Tcl_AppendResult(interp, str, (char *)NULL);
+ lptr = lptr0;
} else {
- Tcl_AppendResult(interp,"[] 0 setdash\n",(char *)NULL);
+ Tcl_AppendResult(interp, "[] 0 setdash\n", (char *)NULL);
}
} else {
- Tcl_AppendResult(interp,"[] 0 setdash\n",(char *)NULL);
+ Tcl_AppendResult(interp, "[] 0 setdash\n", (char *)NULL);
}
- if (s!=string) {
- ckfree(s);
+ if (str != string) {
+ ckfree(str);
}
- if (l!=pattern) {
- ckfree(l);
+ if (lptr != pattern) {
+ ckfree(lptr);
}
- if (Tk_CanvasPsColor(interp, canvas, color)
- != TCL_OK) {
+ if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
return TCL_ERROR;
}
if (stipple != None) {
Tcl_AppendResult(interp, "StrokeClip ", (char *) NULL);
- if (Tk_CanvasPsStipple(interp, canvas,
- stipple) != TCL_OK) {
+ if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
return TCL_ERROR;
}
} else {
diff --git a/generic/tkCmds.c b/generic/tkCmds.c
index 75504bb..15650f2 100644
--- a/generic/tkCmds.c
+++ b/generic/tkCmds.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkCmds.c,v 1.8 1999/12/03 07:14:39 hobbs Exp $
+ * RCS: @(#) $Id: tkCmds.c,v 1.9 1999/12/16 21:57:35 hobbs Exp $
*/
#include "tkPort.h"
@@ -568,10 +568,10 @@ Tk_TkObjCmd(clientData, interp, objc, objv)
int index;
Tk_Window tkwin;
static char *optionStrings[] = {
- "appname", "scaling", NULL
+ "appname", "scaling", "useinputmethods", NULL
};
enum options {
- TK_APPNAME, TK_SCALING
+ TK_APPNAME, TK_SCALING, TK_USE_IM
};
tkwin = (Tk_Window) clientData;
@@ -607,7 +607,7 @@ Tk_TkObjCmd(clientData, interp, objc, objv)
Screen *screenPtr;
int skip, width, height;
double d;
-
+
screenPtr = Tk_Screen(tkwin);
skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin);
@@ -620,7 +620,7 @@ Tk_TkObjCmd(clientData, interp, objc, objv)
d /= WidthMMOfScreen(screenPtr);
Tcl_SetDoubleObj(Tcl_GetObjResult(interp), d);
} else if (objc - skip == 3) {
- if (Tcl_GetDoubleFromObj(interp, objv[2 + skip], &d) != TCL_OK) {
+ if (Tcl_GetDoubleFromObj(interp, objv[2+skip], &d) != TCL_OK) {
return TCL_ERROR;
}
d = (25.4 / 72) / d;
@@ -641,6 +641,40 @@ Tk_TkObjCmd(clientData, interp, objc, objv)
}
break;
}
+ case TK_USE_IM: {
+ TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
+ int skip;
+
+ skip = TkGetDisplayOf(interp, objc-2, objv+2, &tkwin);
+ if (skip < 0) {
+ return TCL_ERROR;
+ } else if (skip) {
+ dispPtr = ((TkWindow *) tkwin)->dispPtr;
+ }
+ if ((objc - skip) == 3) {
+#ifdef TK_USE_INPUT_METHODS
+ /*
+ * In the case where TK_USE_INPUT_METHODS is not defined,
+ * this will be ignored and we will always return 0.
+ * That will indicate to the user that input methods
+ * are just not available.
+ */
+ int bool;
+ if (Tcl_GetBooleanFromObj(interp, objv[2+skip], &bool)
+ != TCL_OK) {
+ return TCL_ERROR;
+ }
+ dispPtr->useInputMethods = bool;
+#endif /* TK_USE_INPUT_METHODS */
+ } else if ((objc - skip) != 2) {
+ Tcl_WrongNumArgs(interp, 2, objv,
+ "?-displayof window? ?boolean?");
+ return TCL_ERROR;
+ }
+ Tcl_SetBooleanObj(Tcl_GetObjResult(interp),
+ dispPtr->useInputMethods);
+ break;
+ }
}
return TCL_OK;
}
@@ -1522,7 +1556,8 @@ TkGetDisplayOf(interp, objc, objv, tkwinPtr)
return 0;
}
string = Tcl_GetStringFromObj(objv[0], &length);
- if ((length >= 2) && (strncmp(string, "-displayof", (unsigned) length) == 0)) {
+ if ((length >= 2) &&
+ (strncmp(string, "-displayof", (unsigned) length) == 0)) {
if (objc < 2) {
Tcl_SetStringObj(Tcl_GetObjResult(interp),
"value for \"-displayof\" missing", -1);
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index cd3615f..abb2b14 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkEvent.c,v 1.6 1999/12/14 06:52:27 hobbs Exp $
+ * RCS: @(#) $Id: tkEvent.c,v 1.7 1999/12/16 21:57:36 hobbs Exp $
*/
#include "tkPort.h"
@@ -669,19 +669,20 @@ Tk_HandleEvent(eventPtr)
* input context for the window if it hasn't already been done
* (XFilterEvent needs this context).
*/
-
- if (!(winPtr->flags & TK_CHECKED_IC)) {
- if (winPtr->dispPtr->inputMethod != NULL) {
- winPtr->inputContext = XCreateIC(
+ if (winPtr->dispPtr->useInputMethods) {
+ if (!(winPtr->flags & TK_CHECKED_IC)) {
+ if (winPtr->dispPtr->inputMethod != NULL) {
+ winPtr->inputContext = XCreateIC(
winPtr->dispPtr->inputMethod, XNInputStyle,
XIMPreeditNothing|XIMStatusNothing,
XNClientWindow, winPtr->window,
XNFocusWindow, winPtr->window, NULL);
+ }
+ winPtr->flags |= TK_CHECKED_IC;
+ }
+ if (XFilterEvent(eventPtr, None)) {
+ goto done;
}
- winPtr->flags |= TK_CHECKED_IC;
- }
- if (XFilterEvent(eventPtr, None)) {
- goto done;
}
#endif /* TK_USE_INPUT_METHODS */
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 8fdbcc9..59e8a7f 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkFont.c,v 1.7 1999/12/14 06:52:28 hobbs Exp $
+ * RCS: @(#) $Id: tkFont.c,v 1.8 1999/12/16 21:57:36 hobbs Exp $
*/
#include "tkPort.h"
@@ -310,6 +310,7 @@ static char *globalFontClass[] = {
"symbol", /* All platforms. */
/* Unix. */
"lucida sans unicode", /* Windows. */
+ "bitstream cyberbit", /* Windows popular CJK font */
"chicago", /* Mac. */
NULL
};
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 6da5416..bf747f5 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: $Id: tkInt.h,v 1.19 1999/12/14 06:52:29 hobbs Exp $
+ * RCS: $Id: tkInt.h,v 1.20 1999/12/16 21:57:36 hobbs Exp $
*/
#ifndef _TKINT
@@ -482,6 +482,7 @@ typedef struct TkDisplay {
#ifdef TK_USE_INPUT_METHODS
XIM inputMethod; /* Input method for this display */
#endif /* TK_USE_INPUT_METHODS */
+ int useInputMethods; /* Whether to use input methods */
Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */
int refCount; /* Reference count of how many Tk applications
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 4686cb3..bc088f9 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWindow.c,v 1.13 1999/12/14 06:52:34 hobbs Exp $
+ * RCS: @(#) $Id: tkWindow.c,v 1.14 1999/12/16 21:57:36 hobbs Exp $
*/
#include "tkPort.h"
@@ -458,6 +458,7 @@ GetScreen(interp, screenName, screenPtr)
dispPtr->refCount = 0;
strncpy(dispPtr->name, screenName, length);
dispPtr->name[length] = '\0';
+ dispPtr->useInputMethods = 0;
OpenIM(dispPtr);
TkInitXId(dispPtr);