Ejemplo n.º 1
0
        private static void SizeLayoutElement(ILayoutElement layoutElement,
                                              float height,
                                              VerticalAlign verticalAlign,
                                              float restrictedHeight,
                                              float? width,
                                              bool variableColumnWidth,
                                              float columnWidth)
        {
            float? newHeight = null;

            // if verticalAlign is "justify" or "contentJustify", 
            // restrict the height to restrictedHeight.  Otherwise, 
            // size it normally
            if (verticalAlign == VerticalAlign.Justify ||
                verticalAlign == VerticalAlign.ContentJustify)
            {
                newHeight = restrictedHeight;
            }
            else
            {
                if (null != layoutElement.PercentHeight)
                    newHeight = CalculatePercentHeight(layoutElement, height);
            }

            if (variableColumnWidth)
                layoutElement.SetLayoutBoundsSize(width, newHeight);
            else
                layoutElement.SetLayoutBoundsSize(columnWidth, newHeight);
        }
Ejemplo n.º 2
0
        private static void SizeLayoutElement(ILayoutElement layoutElement,
                                              float width,
                                              HorizontalAlign horizontalAlign,
                                              float restrictedWidth,
                                              float? height,
                                              bool variableRowHeight,
                                              float rowHeight)
        {
            float? newWidth = null;

            // if horizontalAlign is "justify" or "contentJustify", 
            // restrict the width to restrictedWidth.  Otherwise, 
            // size it normally
            if (horizontalAlign == HorizontalAlign.Justify ||
                horizontalAlign == HorizontalAlign.ContentJustify)
            {
                newWidth = restrictedWidth;
            }
            else
            {
                if (null != layoutElement.PercentWidth)
                    newWidth = CalculatePercentWidth(layoutElement, width);
            }

            if (variableRowHeight)
                layoutElement.SetLayoutBoundsSize(newWidth, height);
            else
                layoutElement.SetLayoutBoundsSize(newWidth, rowHeight);
        }
Ejemplo n.º 3
0
        /**
         *  
         *  This method is called by updateDisplayList() after initial values for 
         *  visibleStartIndex, visibleEndIndex have been calculated.  We 
         *  re-calculateDisplayParameters() to account for the possibility that
         *  larger cells may have been exposed.  Since tileWdth,Height can only
         *  increase, the new visibleStart,EndIndex values will be greater than or
         *  equal to the old ones. 
         */
         /*private void updateVirtualLayout(int unscaledWidth, int unscaledHeight)
         {
            int oldVisibleStartIndex = _visibleStartIndex;
            int oldVisibleEndIndex = _visibleEndIndex;
            calculateDisplayParameters(unscaledWidth, unscaledHeight);  // compute new visibleStart,EndIndex values
            
            // We're responsible for laying out *all* of the elements requested
            // with getVirtualElementAt(), even if they don't fall within the final
            // visible range.  Hide any extra ones.  On the next layout pass, they'll
            // be added to DataGroup::freeRenderers
            
            GroupBase layoutTarget = Target;
            for (int i = oldVisibleStartIndex; i <= oldVisibleEndIndex; i++)
            {
                if ((i >= _visibleStartIndex) && (i <= _visibleEndIndex)) // skip past the visible range
                {
                    i = _visibleEndIndex;
                    continue;
                } 
                //ILayoutElement el = layoutTarget.getVirtualElementAt(i);
                //if (null == el)
                //    continue;
                //el.setLayoutBoundsSize(0, 0);
                //if (el is IVisualElement)
                //    IVisualElement(el).visible = false; 
            }
        } */

        /**
         *  Sets the size and the position of the specified layout element and cell bounds.
         *  Param: element - the element to resize and position.
         *  Param: cellX - the x coordinate of the cell.
         *  Param: cellY - the y coordinate of the cell.
         *  Param: cellWidth - the width of the cell.
         *  Param: cellHeight - the height of the cell.
         */
        private void sizeAndPositionElement(ILayoutElement element,
                                                  int cellX,
                                                  int cellY,
                                                  int cellWidth,
                                                  int cellHeight)
        {
            float childWidth;
            float childHeight;

            // Determine size of the element
            if (_horizontalAlign == HorizontalAlign.Justify)
                childWidth = cellWidth;
            else if (null != element.PercentWidth)
                childWidth = Mathf.Round((float) (cellWidth * element.PercentWidth * 0.01f));
            else
                childWidth = LayoutUtil.GetPreferredBoundsWidth((InvalidationManagerClient) element);

            if (_verticalAlign == global::eDriven.Gui.Layout.VerticalAlign.Justify)
                childHeight = cellHeight;
            else if (null != element.PercentHeight)
                childHeight = Mathf.Round((float) (cellHeight * element.PercentHeight * 0.01f));
            else
                childHeight = LayoutUtil.GetPreferredBoundsHeight((InvalidationManagerClient) element);

            // Enforce min and max limits
            float maxChildWidth = Math.Min(LayoutUtil.GetMaxBoundsWidth((InvalidationManagerClient) element), cellWidth);
            float maxChildHeight = Math.Min(LayoutUtil.GetMaxBoundsHeight((InvalidationManagerClient) element), cellHeight);
            // Make sure we enforce element's minimum last, since it has the highest priority
            childWidth = Math.Max(LayoutUtil.GetMinBoundsWidth((InvalidationManagerClient) element), Math.Min(maxChildWidth, childWidth));
            childHeight = Math.Max(LayoutUtil.GetMinBoundsHeight((InvalidationManagerClient) element), Math.Min(maxChildHeight, childHeight));

            // Size the element
            element.SetLayoutBoundsSize(childWidth, childHeight);

            float x = cellX;
            switch (_horizontalAlign)
            {
                case HorizontalAlign.Right:
                    x += cellWidth - LayoutUtil.GetLayoutBoundsWidth((InvalidationManagerClient) element);
                break;
                case HorizontalAlign.Center:
                    // Make sure division result is integer - Math.floor() the result.
                    x = cellX + Mathf.Floor((cellWidth - LayoutUtil.GetLayoutBoundsWidth((InvalidationManagerClient) element)) / 2);
                break;
            }

            float y = cellY;
            switch (_verticalAlign)
            {
                case VerticalAlign.Bottom:
                    y += cellHeight - LayoutUtil.GetLayoutBoundsHeight((InvalidationManagerClient)element);
                break;
                case VerticalAlign.Middle:
                    // Make sure division result is integer - Math.floor() the result.
                y += Mathf.Floor((cellHeight - LayoutUtil.GetLayoutBoundsHeight((InvalidationManagerClient) element)) / 2);
                break;
            }

            // Position the element
            element.SetLayoutBoundsPosition(x, y);
        }