- nFixed ++;
- fixedSize += child->FixedWith;
- }
-
- if( child->FixedCross && maxCross < child->FixedCross )
- maxCross = child->FixedCross;
- if( child->MinCross && maxCross < child->MinCross )
- maxCross = child->MinCross;
- nChildren ++;
- }
-
- _SysDebug("%p - nChildren = %i, nFixed = %i", Element, nChildren, nFixed);
- if( nChildren > nFixed ) {
- if( Element->Flags & ELEFLAG_VERTICAL )
- dynWith = Element->CachedH - Element->PaddingT
- - Element->PaddingB;
- else
- dynWith = Element->CachedW - Element->PaddingL
- - Element->PaddingR;
- dynWith -= fixedSize;
- if( dynWith < 0 ) return ;
- dynWith /= nChildren - nFixed;
- _SysDebug("%p - dynWith = %i", Element, dynWith);
- }
-
- if( Element->Flags & ELEFLAG_VERTICAL )
- fullCross = Element->CachedW - Element->PaddingL - Element->PaddingR;
- else
- fullCross = Element->CachedH - Element->PaddingT - Element->PaddingB;
-
- _SysDebug("%p - fullCross = %i", Element, fullCross);
-
- // Pass 2 - Set sizes and recurse
- for( child = Element->FirstChild; child; child = child->NextSibling )
- {
- int cross, with;
-
- _SysDebug("%p,%p ->MinCross = %i", Element, child, child->MinCross);
-
-
- // --- Cross Size ---
- if( child->FixedCross )
- cross = child->FixedCross;
- // Expand to fill?
- // TODO: Extra flag so options are (Expand, Equal, Wrap)
- else if( child->Flags & ELEFLAG_NOEXPAND )
- cross = child->MinCross;
- else
- cross = fullCross;
- _SysDebug("%p,%p - cross = %i", Element, child, cross);
- if( Element->Flags & ELEFLAG_VERTICAL )
- child->CachedW = cross;
- else
- child->CachedH = cross;
-
- // --- With Size ---
- if( child->FixedWith)
- with = child->FixedWith;
- else if( child->Flags & ELEFLAG_NOSTRETCH )
- with = child->MinWith;
- else
- with = dynWith;
- _SysDebug("%p,%p - with = %i", Element, child, with);
- if( Element->Flags & ELEFLAG_VERTICAL )
- child->CachedH = with;
- else
- child->CachedW = with;
-
- WM_UpdateDimensions(child, 0);
- }
-}
-
-/**
- * \brief Updates the position of an element
- *
- * The parent element sets the positions of its children
- */
-void WM_UpdatePosition(tElement *Element)
-{
- tElement *child;
- int x, y;
-
- if( Element->Flags & ELEFLAG_NORENDER ) return ;
-
- _SysDebug("Element=%p{PaddingL:%i, PaddingT:%i}",
- Element, Element->PaddingL, Element->PaddingT);
-
- // Initialise
- x = Element->CachedX + Element->PaddingL;
- y = Element->CachedY + Element->PaddingT;
-
- // Update each child
- for(child = Element->FirstChild; child; child = child->NextSibling)
- {
- child->CachedX = x;
- child->CachedY = y;
-
- // Set Alignment
- if( Element->Flags & ELEFLAG_ALIGN_CENTER ) {
- if(Element->Flags & ELEFLAG_VERTICAL )
- child->CachedX += Element->CachedW/2 - child->CachedW/2;
- else
- child->CachedY += Element->CachedH/2 - child->CachedH/2;
- }
- else if( Element->Flags & ELEFLAG_ALIGN_END ) {
- if(Element->Flags & ELEFLAG_VERTICAL )
- child->CachedX += Element->CachedW - child->CachedW;
- else
- child->CachedY += Element->CachedH - child->CachedH;
- }
-
- // Update child's children positions
- WM_UpdatePosition(child);
-
- // Increment
- if(Element->Flags & ELEFLAG_VERTICAL ) {
- y += child->CachedH + Element->GapSize;