Example #1
0
		float WidthOfColumn(MatrixCellEntry[,] matrix, int iCol)
		{
			int maxRows = matrix.GetLength(0);
			for (int iRow=0; iRow < maxRows; iRow++)
			{
				if (matrix[iRow, iCol] != null && matrix[iRow, iCol].ColSpan == 1)
					return matrix[iRow, iCol].Width;
			}
			return 0;
		}
Example #2
0
		float HeightOfRow(Pages pgs, MatrixCellEntry[,] matrix, int iRow)
		{
			Report rpt = pgs.Report;
			WorkClass wc = GetValue(rpt);

			int maxColumns = matrix.GetLength(1);
			float height=0;
			bool bResetAllHeights=false;

			// Handle the corner;  it might span rows & columns
			bool bCorner = false;
			float cornerHeight=0;
			if (iRow == 0 && matrix[0, 0] != null &&
				(this.ColumnGroupings.Items.Count > 1 ||
				this.RowGroupings.Items.Count > 1))
			{
				bCorner = true;				
			}

			for (int iCol=0; iCol < maxColumns; iCol++)
			{
				MatrixCellEntry mce = matrix[iRow, iCol];
				if (mce == null)
					continue;
				if (mce.DisplayItem is Textbox)
				{
					Textbox tb = mce.DisplayItem as Textbox;
					if (tb.CanGrow)
					{
						wc.Data = mce.Data;		// Must set this for evaluation

						Row lrow = wc.Data.Data.Count > 0? wc.Data.Data[0]:null;
						mce.DisplayItem.SetMC(rpt, mce);	// set for use by the display item
						SetGroupingValues(rpt, mce);

						float tbh = tb.RunTextCalcHeight(rpt, pgs.G, lrow);
						if (height < tbh)
						{
							if (bCorner && iCol == 0)	
							{
								cornerHeight = tbh;
							}
							else
							{
								bResetAllHeights = true;
								height = tbh;
							}
						}
					}
				}

				if (bCorner && iCol == 0)
					continue;
				if (height < mce.Height)
					height = mce.Height;
			}

			if (bResetAllHeights)	// If any text forces the row to grow; all heights must be fixed
			{
				for (int iCol=0; iCol < maxColumns; iCol++)
				{
					if (bCorner && iCol == 0)
						continue;
					MatrixCellEntry mce = matrix[iRow, iCol];
					if (mce != null)
						mce.Height = height;
				}
			}

			// Even with expansion room; we might need more space for the corner
			if (bCorner && cornerHeight > matrix[0,0].Height)
			{	// add the additional space needed to the first row's height
				float newRow0Height;
				if (ColumnGroupings.Items.Count == 1)
					newRow0Height = cornerHeight;
				else if (matrix[0,1] != null)
					newRow0Height = matrix[0,1].Height + (cornerHeight - matrix[0,0].Height);
				else
					newRow0Height = (cornerHeight - matrix[0,0].Height);
				height = newRow0Height;
				matrix[0,0].Height = cornerHeight;
				for (int iCol=1; iCol < maxColumns; iCol++)
				{
					MatrixCellEntry mce = matrix[0, iCol];
					if (mce != null)
						mce.Height = newRow0Height;
				}
			}

			return height;
		}