请教fldHeightChanged的处理

sooler 2004-12-06 11:37:17
请教如何处理表中动态创建的Field的fldHeightChangedEvent事件
...全文
83 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sooler 2004-12-09
  • 打赏
  • 举报
回复
给分吧先~~
搞不定再来请教bill大哥
billpalm 2004-12-06
  • 打赏
  • 举报
回复
如不好理解以下代码,可以找到CodeWarrior中自带的mail或者其它处理fldHeightChangedEvent的sample code。

static void NewViewResizeFieldHeight (EventPtr event)
{
Int16 row, i;
Int16 column;
UInt16 newRowID;
UInt16 rowID;
Int16 height;
Int16 freeSpace;
Int16 newHeight;
Int16 maxHeight;
Int16 columnWidth;
FontID currFont;
Boolean insPtState;
FieldPtr fld;
TablePtr table;
RectangleType fieldR;


// 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;

columnWidth = TblGetColumnWidth (table, newTextColumn);

// 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);

insPtState = InsPtEnabled ();
InsPtEnable (false);

TblMarkTableInvalid (table);
TblRedrawTable (table);

InsPtEnable (insPtState);
}
}
}

// 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:

currFont = FntSetFont (EditFont);
newHeight = event->data.fldHeightChanged.newHeight;

if (rowID == newSubjectRow)
maxHeight = maxNewSubjectLines * FntLineHeight ();
else
maxHeight = maxNewAddressLines * FntLineHeight ();

if (rowID != newBodyRow &&
newHeight > maxHeight &&
TblGetRowHeight (table, row) >= maxHeight)
{
FldSetInsPtPosition (fld, event->data.fldHeightChanged.currentPos);
InsPtEnable (true);
}
else
{
RectangleType tableBounds;

TblGetBounds(table, &tableBounds);

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;

TblHandleEvent (table, event);

NewViewResizeBodyField (table);

fld = TblGetCurrentField (table);
NewScrollPosition [rowID] = FldGetScrollPosition (fld);

if (rowID != newBodyRow)
{
TblMarkTableInvalid (table);
TblRedrawTable (table);
}
}
FntSetFont (currFont);
}

NewViewUpdateScrollBar ();
}

3,120

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧