How to change the font in a zTable cell and column and row label

Article ID: 896
Last updated: 05 Feb, 2008
Article ID: 896
Last updated: 05 Feb, 2008
Revision: 1
Views: 3050
Posted: 12 Jan, 1998
by Dean J.
Updated: 05 Feb, 2008
by Dean J.
Problem


How do I change label font to match the cell font in a zTable?


Cause


Font needs to be changed from default.


Action


Follow these steps:
  1. Derive your own class from zTable (Object Factory does this for you).

  2. Override the drawlabel() function in your derived class.

  3. In drawLabel(), lock the canvas.

  4. Create the font you want and push it on the canvas.

    1. Call the base class drawLabel().

    2. Pop font and delete it.

    3. Unlock canvas and return.

  5. In the main window, every time there is a selection change in the table, call setDirty(zTableRegion&) to redraw the previously selected portion. If this is not done, the previously selected portion will revert to the default font setting.

    In the header file:

    class Table1: public zTable{
    public:
    Table1(zWindow *w,zSizer *sz,DWORD s=0,zTableModel *m=0);
    int drawLabel(zDrawEvt *ev);

    In the CPP file:

    int Table1::drawLabel(zDrawEvt *ev){
    canvas()->lock();
    zFont *pFont=new zFont(Modern,1,zPrPoint(0,100),900,ffDontCare);
    canvas()->pushFont(pFont);
    int iret = zTable::drawLabel(ev);
    delete canvas()->popFont();
    canvas()-> unlock();
    return iret;
    }

    To change the font for the entire table, instead of zTable::drawLabel(zDrawEvt *ev) redefine the zTable::draw(zDrawEvt *ev)) method.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 896
Last updated: 05 Feb, 2008
Revision: 1
Views: 3050
Posted: 12 Jan, 1998 by Dean J.
Updated: 05 Feb, 2008 by Dean J.

Others in this category