I've made a table with custom objects in each cell, but the table doesn't 
draw at all !!
I've tried to make a table with text only and nothing, can anybody help?

here is part of my code:

void mydrawCallback (void *tableP,Int16 row, Int16 column, RectangleType 
*bounds);
void InitTableAplicaciones();
void DrawIcon(UInt16 cardNo, LocalID dbID, RectangleType *pos,Boolean large);

MemHandle       dbIDs;
UInt16          numApps;

void InitTableAplicaciones()
{
        FormType        *formP;
        TableType       *tableP;
        Int16 col,row,appIndex=-1;
        
        formP=FrmGetActiveForm();
        tableP=FrmGetObjectPtr(formP,FrmGetObjectIndex(formP,tblAplicaciones));
        
        SysCreateDataBaseList ('appl',0,&numApps,&dbIDs,true);

        for(row=0;row<4;row++)
                for(col=0;col<3;col++)
                {
                        TblSetItemStyle(tableP,row,col,customTableItem);
                        // reset of the cell
                        TblSetItemInt(tableP,row,col,-1);
                        // asign an Application Index
                        if(appIndex++ >= numApps) break;
                        TblSetItemInt(tableP,row,col,appIndex);
                        TblSetRowUsable(tableP,row,true);
                        TblMarkRowInvalid(tableP, row); // Mark it Invalid so it 
draws.                 
                }
        
        // set the custom draw functions
        TblSetCustomDrawProcedure (tableP,0,(TableDrawItemFuncPtr )mydrawCallback);
        TblSetCustomDrawProcedure (tableP,1,(TableDrawItemFuncPtr )mydrawCallback);
        TblSetCustomDrawProcedure (tableP,2,(TableDrawItemFuncPtr )mydrawCallback);
}


void mydrawCallback (void *tableP,Int16 row, Int16 column, RectangleType 
*bounds)
{
        SysDBListItemType *dbList;
        UInt16                  appIndex;
        RectangleType   mybounds;
        
        // get the application list     
        dbList=MemHandleLock(dbIDs);
        if(appIndex=TblGetItemInt(tableP,row,column)==-1)
        {
                MemHandleUnlock(dbIDs);
                return;
        }
        // draw the icon
        mybounds.topLeft=bounds->topLeft;
        DrawIcon(dbList[appIndex].cardNo,dbList[appIndex].dbID,&mybounds,true);
        // draw the name centered below the icon
        WinDrawChars(dbList[appIndex].name,StrLen(dbList[appIndex].name),
                        mybounds.topLeft.x-( (FntLineWidth(dbList[appIndex].name,
                        StrLen(dbList[appIndex].name))>>1) - (mybounds.extent.x>>1) ),
                        mybounds.topLeft.y+mybounds.extent.y-8);
        
        MemHandleUnlock(dbIDs);
}


/*
        ->      pos->topLeft    donde dibujar
        <-      pos->extent             tamaño del ícono
*/
void DrawIcon(UInt16 cardNo, LocalID dbID, RectangleType *pos,Boolean large)
{
        DmOpenRef       dbRead;
        UInt16          resIndex;
        MemHandle       resH;
        BitmapPtr       resP;
        
        dbRead=DmOpenDatabase(cardNo,dbID,dmModeReadOnly);
        if (dbRead)
        {
                resIndex = DmFindResource(dbRead, 'tAIB', (large? 1000 : 1001), NULL);
                if (resIndex!=-1)
                {
                        resH=DmGetResourceIndex(dbRead, resIndex);
                        if(resH!=NULL)
                        {
                                resP=(BitmapPtr)MemHandleLock(resH);
                                WinDrawBitmap(resP,pos->topLeft.x,pos->topLeft.y);
                                pos->extent.x=resP->width;
                                pos->extent.y=resP->height;
                                MemHandleUnlock(resH);
                        }
                        DmReleaseResource(resH);
                }
        DmCloseDatabase(dbRead);
        }
}

Boolean frmMainHandler(EventPtr event)
{
        FormPtr         form;
        Boolean     handled = false;

        switch (event->eType)
        {
                case frmOpenEvent:
                        /* Form needs to be repainted */
                        form = FrmGetActiveForm();
                        InitMain();
                        FrmDrawForm(form);
                        handled = true;
                        break;
                case menuEvent:
                        handled=mnuMainHandler(event->data.menu.itemID);
                        break;
                default:
        }
        return handled;
}


--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to