diff options
-rw-r--r-- | generic/tkTreeStyle.c | 387 |
1 files changed, 297 insertions, 90 deletions
diff --git a/generic/tkTreeStyle.c b/generic/tkTreeStyle.c index 8b3c691..faaec3f 100644 --- a/generic/tkTreeStyle.c +++ b/generic/tkTreeStyle.c @@ -5,14 +5,24 @@ * * Copyright (c) 2002-2006 Tim Baker * - * RCS: @(#) $Id: tkTreeStyle.c,v 1.61 2006/11/12 05:39:23 treectrl Exp $ + * RCS: @(#) $Id: tkTreeStyle.c,v 1.62 2006/11/22 03:33:24 treectrl Exp $ */ #include "tkTreeCtrl.h" #include "tkTreeElem.h" +/* This is the roundUp argument to AllocHax_CAlloc. */ #define ELEMENT_LINK_ROUND 1 +/* Define this for performance gain and increased memory usage. */ +/* When undefined, there is quite a performance hit when elements are + * squeezable and a style has less than its needed width. The memory + * savings are not too great when undefined. */ +#define CACHE_STYLE_SIZE + +/* Define this for performance gain and increased memory usage. */ +#define CACHE_ELEM_SIZE + typedef struct MStyle MStyle; typedef struct IStyle IStyle; typedef struct MElementLink MElementLink; @@ -24,17 +34,17 @@ typedef struct IElementLink IElementLink; */ struct MStyle { - MStyle *master; + MStyle *master; /* Always NULL. Needed to distinguish between + * an MStyle and IStyle. */ Tk_Uid name; int numElements; MElementLink *elements; /* Array of master elements. */ - int vertical; + int vertical; /* -orient */ }; /* * A data structure of the following type is kept for each instance style. - * Instance styles are created when a style is assigned to an item-column - * or rowlabel. + * Instance styles are created when a style is assigned to an item-column. */ struct IStyle { @@ -45,10 +55,12 @@ struct IStyle #ifdef TREECTRL_DEBUG int neededState; #endif +#ifdef CACHE_STYLE_SIZE int minWidth; int minHeight; int layoutWidth; int layoutHeight; +#endif }; #define ELF_eEXPAND_W 0x0001 /* expand Layout.ePadX[0] */ @@ -107,10 +119,12 @@ struct MElementLink struct IElementLink { Element *elem; /* Master or instance element. */ +#ifdef CACHE_ELEM_SIZE int neededWidth; int neededHeight; int layoutWidth; int layoutHeight; +#endif }; static CONST char *MStyleUid = "MStyle", *IStyleUid = "IStyle", @@ -136,6 +150,10 @@ struct Layout IElementLink *eLink; int useWidth; int useHeight; +#ifndef CACHE_ELEM_SIZE + int neededWidth; + int neededHeight; +#endif int x; /* left of ePad */ int y; /* above ePad */ int eWidth; /* ePad + iPad + useWidth + iPad + ePad */ @@ -440,6 +458,82 @@ Style_DoExpandV( /* *---------------------------------------------------------------------- * + * ElementLink_NeededSize -- + * + * Calculate the needed width and height of an element. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static void +Element_NeededSize( + TreeCtrl *tree, /* Widget info. */ + MElementLink *eLink1, /* Master style layout info. */ + Element *elem, /* Master/Instance element. */ + int state, /* STATE_xxx flags. */ + int *widthPtr, /* Out: width */ + int *heightPtr /* Out: height */ + ) +{ + ElementArgs args; + int width, height; + + if ((eLink1->fixedWidth >= 0) && (eLink1->fixedHeight >= 0)) + { + width = eLink1->fixedWidth; + height = eLink1->fixedHeight; + } + else + { + args.tree = tree; + args.state = state; + args.elem = elem; + args.needed.fixedWidth = eLink1->fixedWidth; + args.needed.fixedHeight = eLink1->fixedHeight; + if (eLink1->maxWidth > eLink1->minWidth) + args.needed.maxWidth = eLink1->maxWidth; + else + args.needed.maxWidth = -1; + if (eLink1->maxHeight > eLink1->minHeight) + args.needed.maxHeight = eLink1->maxHeight; + else + args.needed.maxHeight = -1; + (*args.elem->typePtr->neededProc)(&args); + width = args.needed.width; + height = args.needed.height; + + if (eLink1->fixedWidth >= 0) + width = eLink1->fixedWidth; + else if ((eLink1->minWidth >= 0) && + (width < eLink1->minWidth)) + width = eLink1->minWidth; + else if ((eLink1->maxWidth >= 0) && + (width > eLink1->maxWidth)) + width = eLink1->maxWidth; + + if (eLink1->fixedHeight >= 0) + height = eLink1->fixedHeight; + else if ((eLink1->minHeight >= 0) && + (height < eLink1->minHeight)) + height = eLink1->minHeight; + else if ((eLink1->maxHeight >= 0) && + (height > eLink1->maxHeight)) + height = eLink1->maxHeight; + } + + *widthPtr = width; + *heightPtr = height; +} + +/* + *---------------------------------------------------------------------- + * * Style_DoLayoutH -- * * Calculate the horizontal size and position of each element. @@ -492,8 +586,15 @@ Style_DoLayoutH( /* Width before squeezing/expanding */ if (eLink1->onion != NULL) layout->useWidth = 0; - else + else { +#ifdef CACHE_ELEM_SIZE layout->useWidth = eLink2->neededWidth; +#else + Element_NeededSize(drawArgs->tree, eLink1, eLink2->elem, + drawArgs->state, &layout->neededWidth, &layout->neededHeight); + layout->useWidth = layout->neededWidth; +#endif + } for (j = 0; j < 2; j++) { @@ -1582,10 +1683,11 @@ Style_DoLayout( if (style->neededWidth == -1) panic("Style_DoLayout(file %s line %d): style.neededWidth == -1", file, line); +#ifdef CACHE_STYLE_STYLE if (style->minWidth + drawArgs->indent > drawArgs->width) panic("Style_DoLayout(file %s line %d): style.minWidth + drawArgs->indent %d > drawArgs.width %d", file, line, style->minWidth + drawArgs->indent, drawArgs->width); - +#endif Style_DoLayoutH(drawArgs, layouts); for (i = 0; i < masterStyle->numElements; i++) @@ -1603,7 +1705,11 @@ Style_DoLayout( continue; } +#ifdef CACHE_ELEM_SIZE layout->useHeight = eLink2->neededHeight; +#else + layout->useHeight = layout->neededHeight; +#endif /* If a Text Element is given less width than it needs (due to * -squeeze x layout), then it may wrap lines. This means @@ -1615,6 +1721,7 @@ Style_DoLayout( continue; /* Not squeezed */ +#ifdef CACHE_ELEM_SIZE if (layout->useWidth >= eLink2->neededWidth) continue; @@ -1630,6 +1737,10 @@ Style_DoLayout( (layout->useWidth >= eLink2->neededWidth)) continue; #endif +#else + if (layout->useWidth >= layout->neededWidth) + continue; +#endif args.tree = tree; args.state = state; args.elem = eLink2->elem; @@ -1647,8 +1758,10 @@ Style_DoLayout( else layout->useHeight = args.height.height; +#ifdef CACHE_ELEM_SIZE eLink2->layoutWidth = layout->useWidth; eLink2->layoutHeight = layout->useHeight; +#endif } if (neededV) { @@ -1790,62 +1903,19 @@ Style_NeededSize( continue; } - if ((eLink2->neededWidth == -1) || (eLink2->neededHeight == -1)) - { - if ((eLink1->fixedWidth >= 0) && (eLink1->fixedHeight >= 0)) - { - eLink2->neededWidth = eLink1->fixedWidth; - eLink2->neededHeight = eLink1->fixedHeight; - } - else - { - ElementArgs args; - int width, height; - - args.tree = tree; - args.state = state; - args.elem = eLink2->elem; - args.needed.fixedWidth = eLink1->fixedWidth; - args.needed.fixedHeight = eLink1->fixedHeight; - if (eLink1->maxWidth > eLink1->minWidth) - args.needed.maxWidth = eLink1->maxWidth; - else - args.needed.maxWidth = -1; - if (eLink1->maxHeight > eLink1->minHeight) - args.needed.maxHeight = eLink1->maxHeight; - else - args.needed.maxHeight = -1; - (*args.elem->typePtr->neededProc)(&args); - width = args.needed.width; - height = args.needed.height; - - if (eLink1->fixedWidth >= 0) - width = eLink1->fixedWidth; - else if ((eLink1->minWidth >= 0) && - (width < eLink1->minWidth)) - width = eLink1->minWidth; - else if ((eLink1->maxWidth >= 0) && - (width > eLink1->maxWidth)) - width = eLink1->maxWidth; - - if (eLink1->fixedHeight >= 0) - height = eLink1->fixedHeight; - else if ((eLink1->minHeight >= 0) && - (height < eLink1->minHeight)) - height = eLink1->minHeight; - else if ((eLink1->maxHeight >= 0) && - (height > eLink1->maxHeight)) - height = eLink1->maxHeight; - - eLink2->neededWidth = width; - eLink2->neededHeight = height; - - eLink2->layoutWidth = -1; - } +#ifdef CACHE_ELEM_SIZE + if ((eLink2->neededWidth == -1) || (eLink2->neededHeight == -1)) { + Element_NeededSize(tree, eLink1, eLink2->elem, state, + &eLink2->neededWidth, &eLink2->neededHeight); + eLink2->layoutWidth = -1; } - layout->useWidth = eLink2->neededWidth; layout->useHeight = eLink2->neededHeight; +#else + Element_NeededSize(tree, eLink1, eLink2->elem, state, + &layout->useWidth, &layout->useHeight); +#endif + if (squeeze) { if (eLink1->flags & ELF_SQUEEZE_X) @@ -1954,6 +2024,7 @@ Style_NeededSize( *---------------------------------------------------------------------- */ + static void Style_CheckNeededSize( TreeCtrl *tree, /* Widget info. */ @@ -1965,6 +2036,7 @@ Style_CheckNeededSize( { int hasSqueeze = Style_NeededSize(tree, style, state, &style->neededWidth, &style->neededHeight, FALSE); +#ifdef CACHE_STYLE_SIZE if (hasSqueeze) { Style_NeededSize(tree, style, state, &style->minWidth, @@ -1976,6 +2048,7 @@ Style_CheckNeededSize( style->minHeight = style->neededHeight; } style->layoutWidth = -1; +#endif /* CACHE_STYLE_SIZE */ #ifdef TREECTRL_DEBUG style->neededState = state; #endif @@ -1987,6 +2060,37 @@ Style_CheckNeededSize( #endif } +#ifndef CACHE_STYLE_SIZE + +static void +Style_MinSize( + TreeCtrl *tree, /* Widget info. */ + IStyle *style, /* Style info. */ + int state, /* STATE_xxx flags. */ + int *minWidthPtr, + int *minHeightPtr + ) +{ + int i, hasSqueeze = FALSE; + + for (i = 0; i < style->master->numElements; i++) { + MElementLink *eLink1 = &style->master->elements[i]; + if ((eLink1->onion == NULL) && + (eLink1->flags & (ELF_SQUEEZE_X | ELF_SQUEEZE_Y))) { + hasSqueeze = TRUE; + break; + } + } + if (hasSqueeze) { + Style_NeededSize(tree, style, state, minWidthPtr, minHeightPtr, TRUE); + } else { + *minWidthPtr = style->neededWidth; + *minHeightPtr = style->neededHeight; + } +} + +#endif /* !CACHE_STYLE_SIZE */ + /* *---------------------------------------------------------------------- * @@ -2073,9 +2177,20 @@ TreeStyle_UseHeight( IStyle *style = (IStyle *) drawArgs->style; int state = drawArgs->state; struct Layout staticLayouts[STATIC_SIZE], *layouts = staticLayouts; - int width, height; + int width, height, minWidth; +#ifndef CACHE_STYLE_SIZE + int minHeight; +#endif Style_CheckNeededSize(tree, style, state); +#ifdef CACHE_STYLE_SIZE + minWidth = style->minWidth; +#else + if (drawArgs->width < style->neededWidth + drawArgs->indent) + Style_MinSize(tree, style, state, &minWidth, &minHeight); + else + minWidth = style->neededWidth; +#endif /* * If we have: @@ -2087,20 +2202,22 @@ TreeStyle_UseHeight( */ if ((drawArgs->width == -1) || (drawArgs->width >= style->neededWidth + drawArgs->indent) || - (style->neededWidth == style->minWidth)) + (style->neededWidth == minWidth)) { return style->neededHeight; } /* We never lay out the style at less than the minimum width */ - if (drawArgs->width < style->minWidth + drawArgs->indent) - drawArgs->width = style->minWidth + drawArgs->indent; + if (drawArgs->width < minWidth + drawArgs->indent) + drawArgs->width = minWidth + drawArgs->indent; +#ifdef CACHE_STYLE_SIZE /* We have less space than the style needs, and have already calculated * the height of the style at this width. (The height may change because * of text elements wrapping lines). */ if (drawArgs->width == style->layoutWidth) return style->layoutHeight; +#endif STATIC_ALLOC(layouts, struct Layout, style->master->numElements); @@ -2111,8 +2228,10 @@ TreeStyle_UseHeight( STATIC_FREE(layouts, struct Layout, style->master->numElements); +#ifdef CACHE_STYLE_SIZE style->layoutWidth = drawArgs->width; style->layoutHeight = height; +#endif return height; } @@ -2142,11 +2261,26 @@ void TreeStyle_Draw( TreeCtrl *tree = drawArgs->tree; int *bounds = drawArgs->bounds; ElementArgs args; - int i, x, y; + int i, x, y, minWidth, minHeight; struct Layout staticLayouts[STATIC_SIZE], *layouts = staticLayouts; +#define DEBUG_DRAW 0 +#if DEBUG_DRAW int debugDraw = FALSE; +#endif Style_CheckNeededSize(tree, style, drawArgs->state); +#ifdef CACHE_STYLE_SIZE + minWidth = style->minWidth; + minHeight = style->minHeight; +#else + if ((drawArgs->width < style->neededWidth + drawArgs->indent) || + (drawArgs->height < style->neededHeight)) { + Style_MinSize(tree, style, drawArgs->state, &minWidth, &minHeight); + } else { + minWidth = style->neededWidth; + minHeight = style->neededHeight; + } +#endif /* Get the bounds allowed for drawing (in window coordinates), inside * the item-column(s) and inside the header/borders. */ @@ -2158,10 +2292,10 @@ void TreeStyle_Draw( args.display.bounds[3] = MIN(bounds[3], y + drawArgs->height); /* We never lay out the style at less than the minimum size */ - if (drawArgs->width < style->minWidth + drawArgs->indent) - drawArgs->width = style->minWidth + drawArgs->indent; - if (drawArgs->height < style->minHeight) - drawArgs->height = style->minHeight; + if (drawArgs->width < minWidth + drawArgs->indent) + drawArgs->width = minWidth + drawArgs->indent; + if (drawArgs->height < minHeight) + drawArgs->height = minHeight; STATIC_ALLOC(layouts, struct Layout, masterStyle->numElements); @@ -2175,8 +2309,10 @@ void TreeStyle_Draw( { struct Layout *layout = &layouts[i]; +#if DEBUG_DRAW if (debugDraw && layout->master->onion != NULL) continue; +#endif if ((layout->useWidth > 0) && (layout->useHeight > 0)) { @@ -2188,6 +2324,7 @@ void TreeStyle_Draw( args.display.width = layout->useWidth; args.display.height = layout->useHeight; args.display.sticky = layout->master->flags & ELF_STICKY; +#if DEBUG_DRAW if (debugDraw) { XColor *color[3]; @@ -2230,10 +2367,12 @@ void TreeStyle_Draw( layout->eLink->neededWidth, layout->eLink->neededHeight); } else +#endif /* DEBUG_DRAW */ (*args.elem->typePtr->displayProc)(&args); } } +#if DEBUG_DRAW if (debugDraw) for (i = 0; i < masterStyle->numElements; i++) { @@ -2271,6 +2410,7 @@ void TreeStyle_Draw( } } } +#endif /* DEBUG_DRAW */ STATIC_FREE(layouts, struct Layout, masterStyle->numElements); } @@ -2299,14 +2439,35 @@ TreeStyle_UpdateWindowPositions( ) { IStyle *style = (IStyle *) drawArgs->style; + MStyle *masterStyle = style->master; TreeCtrl *tree = drawArgs->tree; int *bounds = drawArgs->bounds; ElementArgs args; - int i, x, y; + int i, x, y, minWidth, minHeight; struct Layout staticLayouts[STATIC_SIZE], *layouts = staticLayouts; /* FIXME: Perhaps remember whether this style has any window * elements */ + for (i = 0; i < masterStyle->numElements; i++) { + if (ELEMENT_TYPE_MATCHES(masterStyle->elements[i].elem->typePtr, &elemTypeWindow)) + break; + } + if (i == masterStyle->numElements) + return; + + Style_CheckNeededSize(tree, style, drawArgs->state); +#ifdef CACHE_STYLE_SIZE + minWidth = style->minWidth; + minHeight = style->minHeight; +#else + if ((drawArgs->width < style->neededWidth + drawArgs->indent) || + (drawArgs->height < style->neededHeight)) { + Style_MinSize(tree, style, drawArgs->state, &minWidth, &minHeight); + } else { + minWidth = style->neededWidth; + minHeight = style->neededHeight; + } +#endif /* Get the bounds allowed for drawing (in window coordinates), inside * the item-column(s) and inside the header/borders. */ @@ -2318,10 +2479,10 @@ TreeStyle_UpdateWindowPositions( args.display.bounds[3] = MIN(bounds[3], y + drawArgs->height); /* We never lay out the style at less than the minimum size */ - if (drawArgs->width < style->minWidth + drawArgs->indent) - drawArgs->width = style->minWidth + drawArgs->indent; - if (drawArgs->height < style->minHeight) - drawArgs->height = style->minHeight; + if (drawArgs->width < minWidth + drawArgs->indent) + drawArgs->width = minWidth + drawArgs->indent; + if (drawArgs->height < minHeight) + drawArgs->height = minHeight; STATIC_ALLOC(layouts, struct Layout, style->master->numElements); @@ -3001,8 +3162,10 @@ TreeStyle_NewInstance( { eLink = ©->elements[i]; eLink->elem = style->elements[i].elem; +#ifdef CACHE_ELEM_SIZE eLink->neededWidth = -1; eLink->neededHeight = -1; +#endif } } @@ -3219,7 +3382,7 @@ Style_Changed( TreeColumn treeColumn; Tcl_HashEntry *hPtr; Tcl_HashSearch search; - int i, columnIndex, layout; + int columnIndex, layout; int updateDInfo = FALSE; IStyle *style; @@ -3236,12 +3399,15 @@ Style_Changed( style = (IStyle *) TreeItemColumn_GetStyle(tree, column); if ((style != NULL) && (style->master == masterStyle)) { +#ifdef CACHE_ELEM_SIZE + int i; for (i = 0; i < masterStyle->numElements; i++) { IElementLink *eLink = &style->elements[i]; /* This is needed if the -width/-height layout options change */ eLink->neededWidth = eLink->neededHeight = -1; } +#endif style->neededWidth = style->neededHeight = -1; Tree_InvalidateColumnWidth(tree, treeColumn); TreeItemColumn_InvalidateSize(tree, column); @@ -3406,7 +3572,9 @@ IStyle_ChangeElementsAux( { eLink = &eLinks[i]; eLink->elem = elemList[i]; +#ifdef CACHE_ELEM_SIZE eLink->neededWidth = eLink->neededHeight = -1; +#endif } } @@ -3633,8 +3801,10 @@ Style_ElemChanged( eLink = &style->elements[masterElemIndex]; if (eLink->elem == masterElem) { +#ifdef CACHE_ELEM_SIZE if (csM & CS_LAYOUT) eLink->neededWidth = eLink->neededHeight = -1; +#endif cMask |= csM; } /* Instance element */ @@ -3642,8 +3812,10 @@ Style_ElemChanged( { args.elem = eLink->elem; eMask = (*masterElem->typePtr->changeProc)(&args); +#ifdef CACHE_ELEM_SIZE if (eMask & CS_LAYOUT) eLink->neededWidth = eLink->neededHeight = -1; +#endif cMask |= eMask; } iMask |= cMask; @@ -3883,7 +4055,9 @@ Style_SetImageOrText( args.change.flagMaster = 0; (void) (*eLink->elem->typePtr->changeProc)(&args); +#ifdef CACHE_ELEM_SIZE eLink->neededWidth = eLink->neededHeight = -1; +#endif style->neededWidth = style->neededHeight = -1; break; } @@ -4329,7 +4503,9 @@ Tree_ElementChangedItself( columnIndex = TreeItemColumn_Index(tree, item, column); +#ifdef CACHE_ELEM_SIZE eLink->neededWidth = eLink->neededHeight = -1; +#endif style->neededWidth = style->neededHeight = -1; Tree_InvalidateColumnWidth(tree, Tree_FindColumn(tree, columnIndex)); @@ -4353,7 +4529,9 @@ void Tree_ElementIterateChanged(TreeIterate iter_, int mask) if (mask & CS_LAYOUT) { +#ifdef CACHE_ELEM_SIZE iter->eLink->neededWidth = iter->eLink->neededHeight = -1; +#endif iter->style->neededWidth = iter->style->neededHeight = -1; Tree_InvalidateColumnWidth(iter->tree, Tree_FindColumn(iter->tree, iter->columnIndex)); @@ -4573,7 +4751,9 @@ TreeStyle_ElementConfigure( (*eMask) = 0; if (isNew) { +#ifdef CACHE_ELEM_SIZE eLink->neededWidth = eLink->neededHeight = -1; +#endif style->neededWidth = style->neededHeight = -1; (*eMask) = CS_DISPLAY | CS_LAYOUT; } @@ -4595,7 +4775,9 @@ TreeStyle_ElementConfigure( if (!isNew && ((*eMask) & CS_LAYOUT)) { +#ifdef CACHE_ELEM_SIZE eLink->neededWidth = eLink->neededHeight = -1; +#endif style->neededWidth = style->neededHeight = -1; } } @@ -6000,15 +6182,21 @@ TreeStyle_Identify( IStyle *style = (IStyle *) drawArgs->style; int state = drawArgs->state; IElementLink *eLink = NULL; - int i; + int i, minWidth, minHeight; struct Layout staticLayouts[STATIC_SIZE], *layouts = staticLayouts; Style_CheckNeededSize(tree, style, state); +#ifdef CACHE_STYLE_SIZE + minWidth = style->minWidth; + minHeight = style->minHeight; +#else + Style_MinSize(tree, style, state, &minWidth, &minHeight); +#endif - if (drawArgs->width < style->minWidth + drawArgs->indent) - drawArgs->width = style->minWidth + drawArgs->indent; - if (drawArgs->height < style->minHeight) - drawArgs->height = style->minHeight; + if (drawArgs->width < minWidth + drawArgs->indent) + drawArgs->width = minWidth + drawArgs->indent; + if (drawArgs->height < minHeight) + drawArgs->height = minHeight; x -= drawArgs->x; @@ -6064,15 +6252,21 @@ TreeStyle_Identify2( IStyle *style = (IStyle *) drawArgs->style; int state = drawArgs->state; IElementLink *eLink; - int i; + int i, minWidth, minHeight; struct Layout staticLayouts[STATIC_SIZE], *layouts = staticLayouts; Style_CheckNeededSize(tree, style, state); +#ifdef CACHE_STYLE_SIZE + minWidth = style->minWidth; + minHeight = style->minHeight; +#else + Style_MinSize(tree, style, state, &minWidth, &minHeight); +#endif - if (drawArgs->width < style->minWidth + drawArgs->indent) - drawArgs->width = style->minWidth + drawArgs->indent; - if (drawArgs->height < style->minHeight) - drawArgs->height = style->minHeight; + if (drawArgs->width < minWidth + drawArgs->indent) + drawArgs->width = minWidth + drawArgs->indent; + if (drawArgs->height < minHeight) + drawArgs->height = minHeight; STATIC_ALLOC(layouts, struct Layout, style->master->numElements); @@ -6247,8 +6441,10 @@ TreeStyle_Remap( for (i = 0; i < styleTo->numElements; i++) { styleFrom->elements[i].elem = styleTo->elements[i].elem; +#ifdef CACHE_ELEM_SIZE styleFrom->elements[i].neededWidth = -1; styleFrom->elements[i].neededHeight = -1; +#endif } for (i = 0; i < styleFromNumElements; i++) { @@ -6400,7 +6596,7 @@ TreeStyle_GetElemRects( { IStyle *style = (IStyle *) drawArgs->style; MStyle *master = style->master; - int i, j, count = 0; + int i, j, count = 0, minWidth, minHeight; struct Layout staticLayouts[STATIC_SIZE], *layouts = staticLayouts; Element *staticElems[STATIC_SIZE], **elems = staticElems; MElementLink *eLink; @@ -6426,10 +6622,17 @@ TreeStyle_GetElemRects( } } - if (drawArgs->width < style->minWidth + drawArgs->indent) - drawArgs->width = style->minWidth + drawArgs->indent; - if (drawArgs->height < style->minHeight) - drawArgs->height = style->minHeight; +#ifdef CACHE_STYLE_SIZE + minWidth = style->minWidth; + minHeight = style->minHeight; +#else + Style_MinSize(drawArgs->tree, style, drawArgs->state, &minWidth, &minHeight); +#endif + + if (drawArgs->width < minWidth + drawArgs->indent) + drawArgs->width = minWidth + drawArgs->indent; + if (drawArgs->height < minHeight) + drawArgs->height = minHeight; STATIC_ALLOC(layouts, struct Layout, master->numElements); @@ -6514,8 +6717,10 @@ TreeStyle_ChangeState( eMask = (*eLink->elem->typePtr->stateProc)(&args); if (eMask) { +#ifdef CACHE_ELEM_SIZE if (eMask & CS_LAYOUT) eLink->neededWidth = eLink->neededHeight = -1; +#endif mask |= eMask; } } @@ -6586,7 +6791,9 @@ Tree_UndefineState( args.elem = eLink->elem; (*args.elem->typePtr->undefProc)(&args); } +#ifdef CACHE_ELEM_SIZE eLink->neededWidth = eLink->neededHeight = -1; +#endif } style->neededWidth = style->neededHeight = -1; TreeItemColumn_InvalidateSize(tree, column); |