// Get the current height of the field;
fld = event->data.fldHeightChanged.pField;
FldGetBounds (fld, &fieldR);
// Get the id of the current row.
table = GetObjectPtr (NewTable);
TblGetSelection (table, &row, &column);
NewViewCurrentRowID = TblGetRowID (table, row);
rowID = NewViewCurrentRowID;
// Is the field's height contracting?
if (event->data.fldHeightChanged.newHeight < fieldR.extent.y)
{
// if there are no items scrolled off the top of the table,
// scroll the text of the field winUp.
if (TblGetRowID (table, 0) == 0)
{
if (rowID == newBodyRow)
{
goto doBodyRowThing;
//return;
}
else
{
TblHandleEvent (table, event);
// Add the freed space to the "body" field.
NewViewResizeBodyField (table);
TblRedrawTable (table);
}
}
// Add an item to the table to fill in the space made available by the
// shortening the field. This is because as the field shortens, we may
// now have space to show the fields above it...picture the bodfy field
// is expanded to fill the screen, as the user deletes lines, and once
// it is small enough not to fill the screen, the field dire3ctly above
// the body (the subject) should now be visible. (ie scroll into view)
else
{
freeSpace = fieldR.extent.y - event->data.fldHeightChanged.newHeight;
newRowID = TblGetRowID (table, 0);
while (newRowID > newToRow && freeSpace)
{
// Add a row to the top of the table an initialize it.
if (newRowID-1 == newBCCRow && (! NewViewShowBCC))
newRowID -= 2;
else
newRowID--;
height = NewViewGetFieldHeight (NewRecord, newRowID, columnWidth);
if (height > freeSpace)
break;
// If there room to scroll a field onto the screen then do it.
TblInsertRow (table, 0);
NewViewInitRow (table, 0, newRowID, height);
freeSpace -= height;
}
if (freeSpace != fieldR.extent.y - event->data.fldHeightChanged.newHeight)
{
// Reinitialize the current row so that it has the correct size.
if (rowID != newBodyRow)
{
height = NewViewGetFieldHeight (NewRecord, rowID, columnWidth);
TblFindRowID (table, rowID, &row);
NewViewInitRow (table, row, rowID, height);
}
// Add the freed space to the "body" field.
NewViewResizeBodyField (table);
// The field's height is expanding, have the table object resize the field.
// OR the field is the body field and we need to do the stuff below anyway.
else
{
doBodyRowThing:
if (rowID != newBodyRow && newHeight > maxHeight)
event->data.fldHeightChanged.newHeight = maxHeight;
else if (rowID == newBodyRow && row == 0)
{
//set the max height based on the font
maxHeight = tableBounds.extent.y;
if (row == 0)
{
//get the max size of the body field
// subtract the fields above it
for (i = 0; i < row; i++)
maxHeight -= TblGetRowHeight (table, i);
}
//is the new height larger than the size that the table want's to grow?
if (newHeight > maxHeight)
// set the new size to the max Size
event->data.fldHeightChanged.newHeight = maxHeight;
}
//in all cases...make sure that the .newHeight is not > than the table height!
if (event->data.fldHeightChanged.newHeight > tableBounds.extent.y)
event->data.fldHeightChanged.newHeight = tableBounds.extent.y;