-#if 1
-void WM_UpdateDimensions(tElement *Element, int Pass)
-{
- int fixedSize = 0, maxCross = 0;
- int nFixed = 0, nChildren = 0;
- int minSize = 0;
- tElement *child;
-
- // Pass zero intialises
- if( Pass == 0 )
- {
- // If not a fixed size element, initialise the sizes
- if( !(Element->Flags & ELEFLAG_FIXEDSIZE) )
- {
- Element->CachedH = 0;
- Element->CachedW = 0;
- if( Element->Size )
- {
- if( Element->Parent->Flags & ELEFLAG_VERTICAL )
- Element->CachedH = Element->Size;
- else
- Element->CachedW = Element->Size;
- }
-
- if( !(Element->Flags & ELEFLAG_NOEXPAND) )
- {
- if( Element->Parent->Flags & ELEFLAG_VERTICAL )
- Element->CachedW = Element->Parent->CachedW;
- else
- Element->CachedH = Element->Parent->CachedH;
- }
- }
- }
-
- for( child = Element->FirstChild; child; child = child->NextSibling )
- {
- WM_UpdateDimensions( child, 0 );
-
- if( Element->Flags & ELEFLAG_VERTICAL )
- {
- if( child->CachedH ) {
- fixedSize += child->CachedH;
- minSize += child->CachedH;
- nFixed ++;
- }
- else
- minSize += child->MinHeight;
-
- if( maxCross < child->CachedW )
- maxCross = child->CachedW;;
- }
- else
- {
- if( child->CachedW ) {
- fixedSize += child->CachedW;
- minSize += child->CachedW;
- nFixed ++;
- }
- else
- minSize += child->MinWidth;
-
- if( maxCross < child->CachedH )
- maxCross = child->CachedH;
- }
- nChildren ++;
- }
- _SysDebug("WM_UpdateDimensions: nFixed=%i, fixedSize=%i, minSize=%i, maxCross=%i",
- nFixed, fixedSize, minSize, maxCross
- );
-
-
- // If we don't have our dimensions, get the child dimensions
- if( Element->CachedW == 0 || Element->CachedH == 0 )
- {
- if( Element->Flags & ELEFLAG_VERTICAL )
- {
- if( Element->CachedW == 0 && maxCross )
- Element->CachedW = Element->PaddingL
- + Element->PaddingR + maxCross;
-
- if( Element->CachedH == 0 && nFixed == nChildren )
- Element->CachedH = Element->PaddingT
- + Element->PaddingB + fixedSize
- + nChildren * Element->GapSize;
- }
- else
- {
- if( maxCross )
- Element->CachedH = Element->PaddingT
- + Element->PaddingB + maxCross;
-
- if( Element->CachedW == 0 && nFixed == nChildren )
- Element->CachedW = Element->PaddingL
- + Element->PaddingR + fixedSize
- + nChildren * Element->GapSize;
- }
- }
-
- // Now, if we have the "length" of the widget, we can size the children
- if( (Element->Flags & ELEFLAG_VERTICAL && Element->CachedH > 0)
- || (!(Element->Flags & ELEFLAG_VERTICAL) && Element->CachedW > 0) )
- {
- int dynSize;
-
- // Calculate the size of dynamically sized elements
- if( Element->Flags & ELEFLAG_VERTICAL )
- dynSize = Element->CachedH - Element->PaddingT
- - Element->PaddingB - fixedSize;
- else
- dynSize = Element->CachedW - Element->PaddingL
- - Element->PaddingR - fixedSize;
- dynSize /= nChildren - nFixed;
-
- // Itterate children again
- for( child = Element->FirstChild; child; child = child->NextSibling )
- {
- int tmp;
-
- // Get the size of them
- if(child->Size)
- tmp = child->Size;
- else
- tmp = dynSize;
-
- if( Element->Flags & ELEFLAG_VERTICAL ) {
- if( tmp < child->MinHeight )
- tmp = child->MinHeight;
- child->CachedH = tmp;
- }
- else {
- if( tmp < child->MinWidth )
- tmp = child->MinWidth;
- child->CachedW = tmp;
- }
-
- WM_UpdateDimensions(child, 1);
- }
- }
-}
-
-#else
-