summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2007-05-04 21:29:22 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2007-05-04 21:29:22 (GMT)
commitb721e1f32dc43b3626d65e9211ae661af0d969f3 (patch)
tree51e7b83d5b0e0635d7c5c5de62858ea248f463ec /generic
parent8d83285f461dd84680e46ac7ff6325f43cf48a74 (diff)
downloadtk-b721e1f32dc43b3626d65e9211ae661af0d969f3.zip
tk-b721e1f32dc43b3626d65e9211ae661af0d969f3.tar.gz
tk-b721e1f32dc43b3626d65e9211ae661af0d969f3.tar.bz2
TIP #145 implementation
Diffstat (limited to 'generic')
-rw-r--r--generic/tkFont.c67
-rw-r--r--generic/tkFont.h6
2 files changed, 50 insertions, 23 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 217efaa..14fe799 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.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: tkFont.c,v 1.33 2007/04/17 14:32:28 dkf Exp $
+ * RCS: @(#) $Id: tkFont.c,v 1.34 2007/05/04 21:29:22 patthoyts Exp $
*/
#include "tkPort.h"
@@ -326,8 +326,6 @@ static char *globalFontClass[] = {
static int ConfigAttributesObj(Tcl_Interp *interp,
Tk_Window tkwin, int objc, Tcl_Obj *const objv[],
TkFontAttributes *faPtr);
-static int CreateNamedFont(Tcl_Interp *interp, Tk_Window tkwin,
- const char *name, TkFontAttributes *faPtr);
static void DupFontObjProc(Tcl_Obj *srcObjPtr, Tcl_Obj *dupObjPtr);
static int FieldSpecified(const char *field);
static void FreeFontObjProc(Tcl_Obj *objPtr);
@@ -677,7 +675,7 @@ Tk_FontObjCmd(
&fa) != TCL_OK) {
return TCL_ERROR;
}
- if (CreateNamedFont(interp, tkwin, name, &fa) != TCL_OK) {
+ if (TkCreateNamedFont(interp, tkwin, name, &fa) != TCL_OK) {
return TCL_ERROR;
}
Tcl_AppendResult(interp, name, NULL);
@@ -686,8 +684,6 @@ Tk_FontObjCmd(
case FONT_DELETE: {
int i;
char *string;
- NamedFont *nfPtr;
- Tcl_HashEntry *namedHashPtr;
/*
* Delete the named font. If there are still widgets using this font,
@@ -700,19 +696,7 @@ Tk_FontObjCmd(
}
for (i = 2; i < objc; i++) {
string = Tcl_GetString(objv[i]);
- namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string);
- if (namedHashPtr == NULL) {
- Tcl_AppendResult(interp, "named font \"", string,
- "\" doesn't exist", NULL);
- return TCL_ERROR;
- }
- nfPtr = (NamedFont *) Tcl_GetHashValue(namedHashPtr);
- if (nfPtr->refCount != 0) {
- nfPtr->deletePending = 1;
- } else {
- Tcl_DeleteHashEntry(namedHashPtr);
- ckfree((char *) nfPtr);
- }
+ TkDeleteNamedFont(interp, tkwin, string);
}
break;
}
@@ -936,7 +920,7 @@ RecomputeWidgets(
/*
*---------------------------------------------------------------------------
*
- * CreateNamedFont --
+ * TkCreateNamedFont --
*
* Create the specified named font with the given attributes in the named
* font table associated with the interp.
@@ -957,8 +941,8 @@ RecomputeWidgets(
*---------------------------------------------------------------------------
*/
-static int
-CreateNamedFont(
+int
+TkCreateNamedFont(
Tcl_Interp *interp, /* Interp for error return. */
Tk_Window tkwin, /* A window associated with interp. */
const char *name, /* Name for the new named font. */
@@ -1006,6 +990,45 @@ CreateNamedFont(
/*
*---------------------------------------------------------------------------
*
+ * TkDeleteNamedFont --
+ *
+ * Delete the named font. If there are still widgets using this
+ * font, then it isn't deleted right away.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+int
+TkDeleteNamedFont(
+ Tcl_Interp *interp, /* Interp for error return. */
+ Tk_Window tkwin, /* A window associated with interp. */
+ CONST char *name) /* Name for the new named font. */
+{
+ TkFontInfo *fiPtr;
+ NamedFont *nfPtr;
+ Tcl_HashEntry *namedHashPtr;
+
+ fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr;
+
+ namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, name);
+ if (namedHashPtr == NULL) {
+ Tcl_AppendResult(interp, "named font \"", name,
+ "\" doesn't exist", (char *) NULL);
+ return TCL_ERROR;
+ }
+ nfPtr = (NamedFont *) Tcl_GetHashValue(namedHashPtr);
+ if (nfPtr->refCount != 0) {
+ nfPtr->deletePending = 1;
+ } else {
+ Tcl_DeleteHashEntry(namedHashPtr);
+ ckfree((char *) nfPtr);
+ }
+ return TCL_OK;
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
* Tk_GetFont --
*
* Given a string description of a font, map the description to a
diff --git a/generic/tkFont.h b/generic/tkFont.h
index 9ea3488..448423d 100644
--- a/generic/tkFont.h
+++ b/generic/tkFont.h
@@ -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: tkFont.h,v 1.9 2006/12/01 20:14:23 kennykb Exp $
+ * RCS: @(#) $Id: tkFont.h,v 1.10 2007/05/04 21:29:22 patthoyts Exp $
*/
#ifndef _TKFONT
@@ -203,6 +203,10 @@ MODULE_SCOPE int TkFontGetPixels(Tk_Window tkwin, int size);
MODULE_SCOPE int TkFontGetPoints(Tk_Window tkwin, int size);
MODULE_SCOPE char ** TkFontGetGlobalClass(void);
MODULE_SCOPE char ** TkFontGetSymbolClass(void);
+MODULE_SCOPE int TkCreateNamedFont(Tcl_Interp *interp, Tk_Window tkwin,
+ CONST char *name, TkFontAttributes *faPtr);
+MODULE_SCOPE int TkDeleteNamedFont(Tcl_Interp *interp,
+ Tk_Window tkwin, CONST char *name);
MODULE_SCOPE int TkFontGetFirstTextLayout(Tk_TextLayout layout,
Tk_Font *font, char *dst);