// Assumes that layoutInfo is up-to-date and that Node that is connected with // columns is already processed and it's size and location calculated. // layoutInfo.Top member reflects the next position below the node // layoutInfo.LevelOffset should reflect the X offset for the child nodes. public static int LayoutColumnHeader(NodeLayoutContextInfo layoutInfo,int x, int y, int clientWidth, int cellHorizontalSpacing) { Node node=layoutInfo.ContextNode; int height=0; foreach(ColumnHeader col in node.NodesColumns) { if(!col.Visible) continue; if(col.SizeChanged) { // Column for child nodes is always placed below the current node and // is not included in the node's rectangle Rectangle bounds=Rectangle.Empty; bounds.X=x; bounds.Y=y; if(col.Width.Relative>0) bounds.Width=(clientWidth*col.Width.Relative)/100-1; else bounds.Width=col.Width.Absolute; if(col.StyleNormal=="" && col.StyleMouseDown=="" && col.StyleMouseOver=="") { bounds.Height=layoutInfo.DefaultHeaderSize.Height; } else { Size sz=Size.Empty; if(col.StyleNormal!="") { ElementStyleLayout.CalculateStyleSize(layoutInfo.Styles[col.StyleNormal],layoutInfo.DefaultFont); sz=layoutInfo.Styles[col.StyleNormal].Size; } if(sz.Height==0) bounds.Height=layoutInfo.DefaultHeaderSize.Height; else bounds.Height=sz.Height; } col.SetBounds(bounds); col.SizeChanged=false; x+=(bounds.Width+cellHorizontalSpacing); if(bounds.Height>height) height=bounds.Height; } else if(col.Bounds.Height>height) height=col.Bounds.Height; } return height; }
private void ProcessNode(NodeLayoutContextInfo layoutInfo) { Node node=layoutInfo.ContextNode; if(node.SizeChanged) { // Calculate size of the node itself... LayoutNode(layoutInfo); // Calculate size and location of node column header if any // if(node.NodesColumnHeaderVisible) // { // layoutInfo.Left+=this.NodeLevelOffset; // LayoutColumnHeader(layoutInfo); // layoutInfo.Left-=this.NodeLevelOffset; // } } else if(node.Bounds.Top!=layoutInfo.Top) { // Adjust top position node.SetBounds(new Rectangle(node.Bounds.X,layoutInfo.Top,node.Bounds.Width,node.Bounds.Height)); foreach(Cell c in node.Cells) c.SetBounds(new Rectangle(c.Bounds.X,layoutInfo.Top,c.Bounds.Width,c.Bounds.Height)); } // Need to set the Top position properly layoutInfo.Top+=(node.Bounds.Height+this.NodeVerticalSpacing); // if(node.Expanded && node.NodesColumnHeaderVisible && node.NodesColumns.Count>0) // layoutInfo.Top+=node.ColumnHeaderHeight; if(node.Expanded) { int originalLevelOffset=layoutInfo.Left; layoutInfo.Left+=this.NodeLevelOffset; ArrayList parentColumns=layoutInfo.ChildColumns; ArrayList childColumns=GetNodeColumnInfo(node); foreach(Node childNode in node.Nodes) { layoutInfo.ContextNode=childNode; layoutInfo.ChildColumns=childColumns; ProcessNode(layoutInfo); } layoutInfo.ChildColumns=parentColumns; layoutInfo.ContextNode=node; layoutInfo.Left=originalLevelOffset; } }
private Size LayoutCellsHorizontal(NodeLayoutContextInfo layoutInfo, int x, int y) { Node node=layoutInfo.ContextNode; int height=0, width=0; for(int i=0;i<node.Cells.Count;i++) { Cell cell=node.Cells[i]; bool bCellVisible=true; // Setup cell layout helper class LayoutCellInfo cellLayout=this.GetLayoutCellInfo(); cellLayout.Top=y; cellLayout.Left=x; cellLayout.CellWidth=0; cellLayout.ContextCell=cell; cellLayout.Graphics=layoutInfo.Graphics; cellLayout.LeftToRight=layoutInfo.LeftToRight; cellLayout.Font=layoutInfo.DefaultFont; if(cell.Layout!=eCellPartLayout.Default) cellLayout.VerticalPartAlignment=(cell.Layout==eCellPartLayout.Vertical); else if(layoutInfo.CellPartLayout!=eCellPartLayout.Default) cellLayout.VerticalPartAlignment=(layoutInfo.CellPartLayout==eCellPartLayout.Vertical); if(layoutInfo.DefaultColumns.Count>0 || layoutInfo.ChildColumns!=null && layoutInfo.ChildColumns.Count>0) { ColumnInfo ci=null; if(layoutInfo.ChildColumns!=null && layoutInfo.ChildColumns.Count>0) ci=layoutInfo.ChildColumns[i] as ColumnInfo; else ci=layoutInfo.DefaultColumns[i] as ColumnInfo; bCellVisible=ci.Visible; cellLayout.CellWidth=ci.Width; } // Prepare union style if(cell.StyleNormal!=null) cellLayout.LayoutStyle=cell.StyleNormal; else cellLayout.LayoutStyle=layoutInfo.DefaultCellStyle; this.LayoutSingleCell(cellLayout); if(bCellVisible) { x+=cell.Bounds.Width; width+=cell.Bounds.Width; if(cell.Bounds.Width>0) { x+=this.CellHorizontalSpacing; width+=this.CellHorizontalSpacing; } if(cell.Bounds.Height>height) height=cell.Bounds.Height; } } // Take last added spacing off x-=this.CellHorizontalSpacing; width-=this.CellHorizontalSpacing; return new Size(width,height); }
private Size LayoutCellsVertical(NodeLayoutContextInfo layoutInfo, int x, int y) { Node node=layoutInfo.ContextNode; int height=0, width=0; eHorizontalAlign align=eHorizontalAlign.Center; int iVisibleCells=0; for(int i=0;i<node.Cells.Count;i++) { Cell cell=node.Cells[i]; bool bCellVisible=true; // Setup cell layout helper class LayoutCellInfo cellLayout=this.GetLayoutCellInfo(); cellLayout.Top=y; cellLayout.Left=x; cellLayout.CellWidth=0; cellLayout.ContextCell=cell; cellLayout.Graphics=layoutInfo.Graphics; cellLayout.LeftToRight=layoutInfo.LeftToRight; cellLayout.Font=layoutInfo.DefaultFont; if(layoutInfo.DefaultColumns.Count>0 || layoutInfo.ChildColumns!=null && layoutInfo.ChildColumns.Count>0) { ColumnInfo ci=null; if(layoutInfo.ChildColumns!=null && layoutInfo.ChildColumns.Count>0) ci=layoutInfo.ChildColumns[i] as ColumnInfo; else ci=layoutInfo.DefaultColumns[i] as ColumnInfo; bCellVisible=ci.Visible; cellLayout.CellWidth=ci.Width; } // Prepare union style if(cell.StyleNormal!=null) cellLayout.LayoutStyle=cell.StyleNormal; else cellLayout.LayoutStyle=layoutInfo.DefaultCellStyle; this.LayoutSingleCell(cellLayout); cell.SetVisible(bCellVisible); if(bCellVisible) { iVisibleCells++; y+=cell.Bounds.Height; height+=cell.Bounds.Height; if(cell.Bounds.Height>0) { y+=this.CellVerticalSpacing; height+=this.CellVerticalSpacing; } if(cell.Bounds.Width>width) width=cell.Bounds.Width; } } // Take last added spacing off y-=this.CellVerticalSpacing; height-=this.CellVerticalSpacing; // Additional pass needed if horizontal alignment is other than left and there is more than one cell visible if(align!=eHorizontalAlign.Left && iVisibleCells>1) { foreach(Cell cell in node.Cells) { if(!cell.IsVisible) continue; if(align==eHorizontalAlign.Center) this.Offset(cell,(width-cell.Bounds.Width)/2,0); else // Right aligned cells this.Offset(cell,width-cell.Bounds.Width,0); } } return new Size(width,height); }
public Size LayoutCells(NodeLayoutContextInfo layoutInfo, int x, int y) { eCellLayout layout=layoutInfo.CellLayout; if(layoutInfo.ContextNode.CellLayout!=layoutInfo.CellLayout && layoutInfo.ContextNode.CellLayout!=eCellLayout.Default) layout=layoutInfo.ContextNode.CellLayout; if(layout==eCellLayout.Horizontal || layout==eCellLayout.Default) return this.LayoutCellsHorizontal(layoutInfo,x,y); else return this.LayoutCellsVertical(layoutInfo,x,y); }