using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using DevComponents.DotNetBar.SuperGrid.Primitives;
using DevComponents.DotNetBar.SuperGrid.Style;
namespace DevComponents.DotNetBar.SuperGrid
{
    /// 
    /// Represents a grid row consisting of one or more grid cells.
    /// 
    public class GridRow : GridContainer
    {
        #region Constants
        private const int SeparatorHeight = 2;
        #endregion
        #region Static data
        private static bool _dragSelection;
        private static bool _dragStarted;
        private static FloatWindow _separatorFw;
        private static FloatWindow _headerFw;
        #endregion
        #region Private variables
        private readonly GridCellCollection _Cells;
        private int _AnchorIndex;
        private int _RowHeight = -1;
        private int _PreDetailRowHeight = -1;
        private int _PostDetailRowHeight = -1;
        private int _EffectivePreDetailRowHeight;
        private int _EffectivePostDetailRowHeight;
        private Rs _States;
        private RowArea _HitArea;
        private GridContainer _HitItem;
        private RowArea _LastArea;
        private RowArea _MouseDownHitArea;
        private GridContainer _MouseDownHitRow;
        private Point _MouseDownPoint;
        private int _MouseDownDelta;
        private GridContainer _SeparatorRow;
        private string _InfoText;
        private Rectangle _InfoImageBounds;
        private Rectangle _ExpandButtonBounds;
        private object _DataItem;
        private int _DataItemIndex = -1;
        private GridCell _EmptyRenderCell;
        private GridCell _EmptySelectionCell;
        private ushort _ArrangeLayoutCount;
        private ushort _MeasureCount;
        private Size _RowHeaderSize;
        private ushort _StyleUpdateCount;
        private CellVisualStyles _EffectiveCellStyles;
        private CellMergeMode _CellMergeMode = CellMergeMode.NotSet;
        private GridPanel _AllocPanel;
        #endregion
        #region Constructors
        /// 
        /// Creates a new GridRow
        /// 
        public GridRow()
        {
            SetState(Rs.AllowEdit, true);
            SetState(Rs.Visible, true);
            _Cells = new GridCellCollection();
            _Cells.CollectionChanged += CellsCollectionChanged;
        }
        /// 
        /// Creates a new GridRow
        /// 
        /// 
        public GridRow(string text)
            : this()
        {
            GridCell cell = new GridCell();
            cell.Value = text;
            _Cells.Add(cell);
        }
        /// 
        /// Creates a new GridRow
        /// 
        /// 
        public GridRow(IEnumerable cells)
            : this()
        {
            foreach (GridCell cell in cells)
                _Cells.Add(cell);
        }
        /// 
        /// Creates a new GridRow
        /// 
        /// 
        public GridRow(IEnumerable