From 32492bfa784837e0da5d0a0b4bc4d08774277413 Mon Sep 17 00:00:00 2001 From: treectrl Date: Sun, 29 Dec 2002 02:37:37 +0000 Subject: Define TreeStyle_ValidateElements. --- generic/tkTreeStyle.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/generic/tkTreeStyle.c b/generic/tkTreeStyle.c index 4e3566f..b169846 100644 --- a/generic/tkTreeStyle.c +++ b/generic/tkTreeStyle.c @@ -1208,8 +1208,12 @@ static void Style_DoLayout(StyleDrawArgs *drawArgs, struct Layout layouts[20], c int state = drawArgs->state; int i; - if (style->neededWidth == -1) panic("Style_DoLayout(file %s line %d): style.neededWidth == -1", file, line); - if (style->minWidth > drawArgs->width) panic("Style_DoLayout: style.minWidth %d > drawArgs.width %d", style->minWidth, drawArgs->width); + if (style->neededWidth == -1) + panic("Style_DoLayout(file %s line %d): style.neededWidth == -1", + file, line); + if (style->minWidth > drawArgs->width) + panic("Style_DoLayout: style.minWidth %d > drawArgs.width %d", + style->minWidth, drawArgs->width); Style_DoLayoutH(drawArgs, layouts); @@ -3526,6 +3530,31 @@ int TreeStyle_GetSortData(TreeCtrl *tree, TreeStyle style_, int type, long *lv, return TCL_ERROR; } +int TreeStyle_ValidateElements(StyleDrawArgs *drawArgs, int objc, Tcl_Obj *CONST objv[]) +{ + Style *style = (Style *) drawArgs->style; + Style *master = style->master ? style->master : style; + Element *elem; + ElementLink *eLink; + int i; + + for (i = 0; i < objc; i++) + { + if (Element_FromObj(drawArgs->tree, objv[i], &elem) != TCL_OK) + return TCL_ERROR; + + eLink = Style_FindElem(drawArgs->tree, master, elem, NULL); + if (eLink == NULL) + { + FormatResult(drawArgs->tree->interp, + "style %s does not use element %s", + style->name, elem->name); + return TCL_ERROR; + } + } + return TCL_OK; +} + int TreeStyle_GetElemRects(StyleDrawArgs *drawArgs, int objc, Tcl_Obj *CONST objv[], XRectangle rects[20]) { -- cgit v0.12