Ejemplo n.º 1
0
        /// <summary>
        /// Calculates cell areas
        /// </summary>
        /// <param name="aRect">
        /// Area occupied by widget <see cref="CellRectangle"/>
        /// </param>
        protected virtual void CalculateCellAreas(CellRectangle aRect)
        {
//			Cairo.Rectangle rect = aRect.CopyAndShrink (Padding);
            CellRectangle rect = aRect.Copy();

            rect.Shrink(Padding);
            box.DoCalculateCellAreas(rect);
            rect = null;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Calculates cell areas
        /// </summary>
        /// <param name="aRect">
        /// Bounding rectangle <see cref="Cairo.Rectangle"/>
        /// </param>
        public static void HBoxCalculateCellAreas(DrawingCellBox aBox, CellRectangle aRect)
        {
            CellRectangle rect = aRect.Copy();

            rect.Shrink(aBox.Padding);
            double start = rect.X;
            double end = System.Convert.ToInt32(rect.Width + rect.X);
            double w, h = 0;
            double cellTop    = rect.Y;
            double cellHeight = System.Convert.ToInt32(rect.Height);

            if (aBox.Homogeneous == true)
            {
                double cw, ch = cw = 0;
                for (int i = 0; i < aBox.Count; i++)
                {
                    if (aBox.Cells[i].IsVisible == false)
                    {
                        aBox.Cells[i].Area.Set(0, 0, 0, 0);
                        continue;
                    }
                    aBox.Cells[i].GetCellSize(out w, out h);
                    if (w > cw)
                    {
                        cw = w;
                    }
                    if (h > ch)
                    {
                        ch = h;
                    }
                }
                int j = 0;
                for (int i = 0; i < aBox.Count; i++)
                {
                    if (aBox.Cells[i].IsVisible == true)
                    {
                        aBox.Cells[i].Area.Set(j * cw, cellTop, cw, cellHeight);
                        j++;
                    }
                }
                return;
            }

            IDrawingCell expandedCell = null;

            for (int i = 0; i < aBox.Count; i++)
            {
                if (aBox.Cells[i].IsVisible == false)
                {
                    aBox.Cells[i].Area.Set(0, 0, 0, 0);
                    continue;
                }
                if (aBox.Cells[i].Expanded == true)
                {
                    expandedCell = aBox.Cells[i];
                    break;
                }
                aBox.Cells[i].GetCellSize(out w, out h);
                aBox.Cells[i].Area.Set(start, cellTop, w, cellHeight);
                start += w + aBox.Spacing;
            }
            if (expandedCell != null)
            {
                for (int i = aBox.Count - 1; i > -1; i--)
                {
                    if (aBox.Cells[i].IsVisible == false)
                    {
                        aBox.Cells[i].Area.Set(0, 0, 0, 0);
                        continue;
                    }
                    if (aBox.Cells[i].Expanded == true)
                    {
                        break;
                    }
                    aBox.Cells[i].GetCellSize(out w, out h);
                    aBox.Cells[i].Area.Set(end - w, cellTop, w, cellHeight);
                    end -= w + aBox.Spacing;
                }
                if (expandedCell.IsVisible == true)
                {
                    expandedCell.Area.Set(start, cellTop, end - start, cellHeight);
                }
                else
                {
                    expandedCell.Area.Set(0, 0, 0, 0);
                }
            }
            aBox.RecalcChildren();
        }