public GUIGridCell OnDown(int x)
        {
            GUIGridRow row = Row.GetRowAt(_control.YPosition + Row.RenderHeight + 1);

            if (row == null)
            {
                return(null);
            }
            return(GetColumnAt(row, x));
        }
        public GUIGridCell OnUp(int x)
        {
            GUIGridRow row = Row.GetRowAt(_control.YPosition - 1);

            if (row == null)
            {
                return(null);
            }
            return(GetColumnAt(row, x));
        }
 public GUIGridCell GetColumnAt(GUIGridRow row, int x)
 {
     for (int column = 0; column < row.Count; column++)
     {
         GUIGridCell cell = row.Columns[column];
         if (x >= cell._positionX && x < cell._positionX + cell.RenderWidth)
         {
             return(cell);
         }
     }
     return(null);
 }
 private void SetInitialSelectedItem()
 {
     if (SelectedGridItem != null)
     {
         return;
     }
     if (Count > 0)
     {
         GUIGridRow row = _rows[0];
         if (row.Count > 0)
         {
             SelectedGridItem = row.Columns[0];
             _cursorPositionX = SelectedGridItem.Control.XPosition + (SelectedGridItem.RenderWidth / 2);
         }
     }
 }
        private void LayoutColumns(GUIGridRow Row, out int rowWidth)
        {
            rowWidth = TotalWidth;
            if (Row.Count == 0)
            {
                return;
            }
            int width       = 0;
            int columnsLeft = 0;

            for (int column = 0; column < Row.Count; column++)
            {
                Row.Columns[column].CalculatedWidth = 0;
                if (Row.Columns[column].AbsoluteWidth > 0)
                {
                    width += Row.Columns[column].AbsoluteWidth;
                }
                else if (Row.Columns[column].RelativeWidth > 0)
                {
                    width += Row.Columns[column].RenderWidth;
                }
                else
                {
                    columnsLeft++;
                }
            }
            rowWidth = width;
            if (columnsLeft == 0)
            {
                return;
            }
            int widthLeft = TotalWidth - width;

            widthLeft /= columnsLeft;
            if (widthLeft > 0)
            {
                rowWidth = TotalWidth;
                for (int column = 0; column < Row.Count; column++)
                {
                    if (Row.Columns[column].AbsoluteWidth <= 0 && Row.Columns[column].RelativeWidth <= 0)
                    {
                        Row.Columns[column].CalculatedWidth = widthLeft;
                    }
                }
            }
        }
        private GUIGridCell GetItemAt(int x, int y)
        {
            if (Count == 0)
            {
                return(null);
            }
            GUIGridRow row = _rows[0].GetRowAt(y);

            if (row == null)
            {
                return(null);
            }
            if (row.Count == 0)
            {
                return(null);
            }
            return(row.Columns[0].GetColumnAt(row, x));
        }
Example #7
0
 private void LayoutColumns(GUIGridRow Row, out int rowWidth)
 {
   rowWidth = TotalWidth;
   if (Row.Count == 0)
   {
     return;
   }
   int width = 0;
   int columnsLeft = 0;
   for (int column = 0; column < Row.Count; column++)
   {
     Row.Columns[column].CalculatedWidth = 0;
     if (Row.Columns[column].AbsoluteWidth > 0)
     {
       width += Row.Columns[column].AbsoluteWidth;
     }
     else if (Row.Columns[column].RelativeWidth > 0)
     {
       width += Row.Columns[column].RenderWidth;
     }
     else
     {
       columnsLeft++;
     }
   }
   rowWidth = width;
   if (columnsLeft == 0)
   {
     return;
   }
   int widthLeft = TotalWidth - width;
   widthLeft /= columnsLeft;
   if (widthLeft > 0)
   {
     rowWidth = TotalWidth;
     for (int column = 0; column < Row.Count; column++)
     {
       if (Row.Columns[column].AbsoluteWidth <= 0 && Row.Columns[column].RelativeWidth <= 0)
       {
         Row.Columns[column].CalculatedWidth = widthLeft;
       }
     }
   }
 }
Example #8
0
 public GUIGridCell(GUIGridRow row)
 {
   _row = row;
 }
Example #9
0
 public GUIGridCell GetColumnAt(GUIGridRow row, int x)
 {
   for (int column = 0; column < row.Count; column++)
   {
     GUIGridCell cell = row.Columns[column];
     if (x >= cell._positionX && x < cell._positionX + cell.RenderWidth)
     {
       return cell;
     }
   }
   return null;
 }
 public GUIGridCell(GUIGridRow row)
 {
     _row = row;
 }