//---------------------------------------------------------------------- protected internal override void DrawFocused() { if (IsOpen) { int iLinesDisplayed = Math.Min(siMaxLineDisplayed, Items.Count); var rect = new Rectangle(LayoutRect.X, LayoutRect.Bottom, LayoutRect.Width, iLinesDisplayed * (Screen.Style.MediumFont.LineSpacing + TextPadding.Vertical) + Padding.Vertical); Screen.DrawBox(Screen.Style.ListViewStyle.ListViewFrame, rect, Screen.Style.ListViewStyle.ListViewFrameCornerSize, Color.White); int iMaxIndex = Math.Min(Items.Count - 1, ScrollItemOffset + iLinesDisplayed - 1); for (int iIndex = ScrollItemOffset; iIndex <= iMaxIndex; iIndex++) { if (Screen.IsActive && miHoveredItemIndex == iIndex) { Screen.DrawBox(Screen.Style.DropDownBoxEntryHoverOverlay, new Rectangle(LayoutRect.X + TextPadding.Left, LayoutRect.Bottom + (Screen.Style.MediumFont.LineSpacing + TextPadding.Vertical) * (iIndex - ScrollItemOffset) + TextPadding.Top, LayoutRect.Width - TextPadding.Horizontal, Screen.Style.MediumFont.LineSpacing + TextPadding.Vertical + 10), 10, Color.White); } Items[iIndex].Draw(); } mScrollbar.Draw(); } }
//---------------------------------------------------------------------- public override void Draw() { if (Texture != null) { Screen.DrawBox(Texture, new Rectangle(LayoutRect.X + Margin.Left, LayoutRect.Y + Margin.Top, LayoutRect.Width - Margin.Horizontal, LayoutRect.Height - Margin.Vertical), CornerSize, Color.White); } if (DoClipping) { Screen.PushScissorRectangle(new Rectangle(LayoutRect.X + Padding.Left + Margin.Left, LayoutRect.Y + Padding.Top + Margin.Top, LayoutRect.Width - Padding.Horizontal - Margin.Horizontal, LayoutRect.Height - Padding.Vertical - Margin.Vertical)); } base.Draw(); if (DoClipping) { Screen.PopScissorRectangle(); } if (EnableScrolling) { Scrollbar.Draw(); } }
//---------------------------------------------------------------------- public override void Draw() { Screen.DrawBox(Style.ListViewFrame, LayoutRect, Style.ListViewFrameCornerSize, Color.White); if (DisplayColumnHeaders) { int iColX = 0; foreach (ListViewColumn col in Columns) { Screen.DrawBox(Style.ColumnHeaderFrame, new Rectangle(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top, col.Width, Style.RowHeight), Style.ColumnHeaderCornerSize, Color.White); if (col.Label != null) { col.Label.Draw(); } else { col.Image.Draw(); } iColX += col.Width + ColSpacing; } } Screen.PushScissorRectangle(new Rectangle(LayoutRect.X + Padding.Left, LayoutRect.Y + Padding.Top + (DisplayColumnHeaders ? Style.RowHeight : 0), LayoutRect.Width - Padding.Horizontal, LayoutRect.Height - Padding.Vertical - (DisplayColumnHeaders ? Style.RowHeight : 0))); int iRowIndex = 0; foreach (ListViewRow row in Rows) { int iRowY = GetRowY(iRowIndex); if ((iRowY + Style.RowHeight + Style.RowSpacing < 0) || (iRowY > LayoutRect.Height - Padding.Vertical)) { iRowIndex++; continue; } if (MergeColumns) { Rectangle rowRect = new Rectangle(LayoutRect.X + Padding.Left, LayoutRect.Y + Padding.Top + iRowY, LayoutRect.Width - Padding.Horizontal, Style.RowHeight); Screen.DrawBox(SelectedRow == row ? Style.SelectedCellFrame : Style.CellFrame, rowRect, Style.CellCornerSize, Color.White); if (HasFocus && FocusedRow == row) { if (SelectedRow != row) { Screen.DrawBox(Style.CellFocusOverlay, rowRect, Style.CellCornerSize, Color.White); } else if (Style.SelectedCellFocusOverlay != null) { Screen.DrawBox(Style.SelectedCellFocusOverlay, rowRect, Style.CellCornerSize, Color.White); } } if (HoveredRow == row && !IsDragging) { if (SelectedRow != row) { Screen.DrawBox(Style.CellHoverOverlay, rowRect, Style.CellCornerSize, Color.White); } else if (Style.SelectedCellHoverOverlay != null) { Screen.DrawBox(Style.SelectedCellHoverOverlay, rowRect, Style.CellCornerSize, Color.White); } } } int iColX = 0; for (int i = 0; i < row.Cells.Length; i++) { ListViewColumn col = Columns[i]; Rectangle rowRect = new Rectangle(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top + iRowY, col.Width, Style.RowHeight); if (!MergeColumns) { Screen.DrawBox(SelectedRow == row ? Style.SelectedCellFrame : Style.CellFrame, rowRect, Style.CellCornerSize, Color.White); if (HasFocus && FocusedRow == row) { if (SelectedRow != row) { Screen.DrawBox(Style.CellFocusOverlay, rowRect, Style.CellCornerSize, Color.White); } else if (Style.SelectedCellFocusOverlay != null) { Screen.DrawBox(Style.SelectedCellFocusOverlay, rowRect, Style.CellCornerSize, Color.White); } } if (HoveredRow == row && !IsDragging) { if (SelectedRow != row) { Screen.DrawBox(Style.CellHoverOverlay, rowRect, Style.CellCornerSize, Color.White); } else if (Style.SelectedCellHoverOverlay != null) { Screen.DrawBox(Style.SelectedCellHoverOverlay, rowRect, Style.CellCornerSize, Color.White); } } } row.Cells[i].Draw(new Point(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top + iRowY)); iColX += col.Width + ColSpacing; } iRowIndex++; } if (NewRowText != null) { int iRowY = GetRowY(iRowIndex); Screen.DrawBox(mbIsHoveringNewRow ? Style.NewRowHoveredFrame : Style.NewRowFrame, new Rectangle(LayoutRect.X + Padding.Left, LayoutRect.Y + Padding.Top + iRowY, LayoutRect.Width - Padding.Horizontal, Style.RowHeight), Style.NewRowFrameCornerSize, Color.White); Vector2 vTextPos = new Vector2(LayoutRect.X + Padding.Left + Style.NewRowHorizontalPadding, LayoutRect.Y + Padding.Top + iRowY + Style.RowHeight / 2f - (int)(Screen.Style.MediumFont.LineSpacing * 0.9f / 2f) + Screen.Style.MediumFont.YOffset); Screen.Game.SpriteBatch.DrawString(Screen.Style.MediumFont, NewRowText, vTextPos, mbIsHoveringNewRow ? Style.NewRowHoveredTextColor : Style.NewRowTextColor); iRowIndex++; } if (HoveredRow != null && !IsDragging) { foreach (Button button in ActionButtons) { button.Draw(); } } if (IsDragging && HitBox.Contains(mHoverPoint)) { int iX = LayoutRect.X + Padding.Left; int iWidth = LayoutRect.Width - Padding.Horizontal; if (HoveredRow != null) { int iY = LayoutRect.Y + Padding.Top + GetRowY(Rows.IndexOf(HoveredRow) + (mbInsertAfter ? 1 : 0)) - (Style.RowSpacing + Screen.Style.ListRowInsertMarker.Height) / 2; Rectangle markerRect = new Rectangle(iX, iY, iWidth, Screen.Style.ListRowInsertMarker.Height); Screen.DrawBox(Screen.Style.ListRowInsertMarker, markerRect, Screen.Style.ListRowInsertMarkerCornerSize, Color.White); } else if (IsHovered) { int iY = LayoutRect.Y + Padding.Top + (mbInsertAfter ? GetRowY(Rows.Count) : 0) - (Style.RowSpacing + Screen.Style.ListRowInsertMarker.Height) / 2; Rectangle markerRect = new Rectangle(iX, iY, iWidth, Screen.Style.ListRowInsertMarker.Height); Screen.DrawBox(Screen.Style.ListRowInsertMarker, markerRect, Screen.Style.ListRowInsertMarkerCornerSize, Color.White); } } Screen.PopScissorRectangle(); Scrollbar.Draw(); }