Hi Greg,
yes, the table starts properly at row 0. Here is a code snippet from my table
initialization:
----------------
TblUnhighlightSelection (table);
for (i=0; i < numRows; i++)
{
TblSetRowHeight(table, i, FntCharHeight());
TblSetRowStaticHeight(table, i, true);
TblSetItemStyle (table, i, 0, customTableItem);
TblSetItemStyle (table, i, 1, customTableItem);
TblSetRowUsable (table, i, false);
}
TblSetColumnUsable (table, 0, true);
TblSetColumnUsable (table, 1, true);
TblSetCustomDrawProcedure (table, 0, (TableDrawItemFuncPtr) DrawRow);
TblSetCustomDrawProcedure (table, 1, (TableDrawItemFuncPtr) DrawRow);
TblSetColumnSpacing(table, 0, 2);
TblSetColumnSpacing(table, 1, 0);
//SclSetScrollBar (scroll, 0, 0, numRecords,numRows);
LoadDataIntoTable (form, numRows, lookup);
---------
And here goes my "DrawRow" callback:
--------
static Err DrawRow (TablePtr table, Int16 row, Int16 column, RectangleType*
bounds)
{
dataRecordPtr rec;
// Err error;
// MemHandle recordHandle;
UInt16 rowID;
Coord width;
RectangleType drawBounds;
Int16 numRows;
Int16 numRecords;
ScrollBarPtr scroll;
FormPtr form;
form = FrmGetActiveForm();
scroll = FrmGetObjectPtr (form,
FrmGetObjectIndex (form, DataContentsScrollVert));
rowID = TblGetRowID (table, row);
TblGetBounds (table, &drawBounds);
//numRows =TblGetNumberOfRows (table);
numRows = drawBounds.extent.y / FntCharHeight();
numRecords = DmNumRecordsInCategory (AppDB, dmAllCategories);
width = (drawBounds.extent.x - drawBounds.topLeft.x - 2) / 2;
TblSetColumnWidth (table, column, width);
bounds->topLeft.x += 2;
bounds->topLeft.y += 2;
rec = list[rowID];
/*
error = GetRecord (AppDB, rowID, &rec, &recordHandle);
if (error)
return (error);
*/
switch (column)
{
case ColFirstName:
WinDrawTruncChars (rec->firstname,
StrLen(rec->firstname), bounds->topLeft.x, bounds->topLeft.y, width);
break;
case ColLastName:
WinDrawTruncChars (rec->lastname,
StrLen(rec->lastname), bounds->topLeft.x, bounds->topLeft.y,
width);
break;
}
// MemHandleUnlock (recordHandle);
return errNone;
}
------
The "bounds" structure gets automatically passed to the callback routine when
the table needs to be drawn, but the very first time this happens,
bounds->topLeft.x is wrong.
Thanks for your help,
Anne-Marie
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/