MFC Grid manual

IForEach Class Reference

Interface to iterate items in the CGrid. More...

#include <Dapfor/GUI/IForEach.h>

List of all members.


Public Member Functions

virtual bool operator() (CGrid &grid, HITEM item, Common::CDataObject *pDO)=0

Detailed Description

Interface to iterate items in the CGrid.

ThreadSafety:
The operator () will be always called in the GUI thread.
Version:
2.0.0 Initial version
Example
#include <Dapfor/GUI/IForEach.h>

//The functor that counts visible and invisible rows in the grid
class RowsCounter : public Dapfor::GUI::IForEach
{
public:
    int GetVisibleRows() const {return m_VisibleRows;}
    int GetInvisibleRows() const {return m_InvisibleRows;}

    virtual bool operator () (Dapfor::GUI::CGrid& grid, Dapfor::GUI::HITEM item, Dapfor::Common::CDataObject* pDO)
    {
        if(grid.IsVisible(item))
        {
            //Increment count of visible rows
            m_VisibleRows++;
        }
        else
        {
            //Increment count of invisible rows
            m_InvisibleRows++;
        }

        //Continue iterations
        return true;
    }

private:
    int m_VisibleRows;
    int m_InvisibleRows;
};


//How to use:

//the functor is applied to both visible and invisible items
RowsCounter functor1;
m_Grid.ForEach(functor1);

//the functor is applied only to visible rows
//functor2.GetInvisibleRows() will get zero.
RowsCounter functor2;
m_Grid.ForEachVisible(functor2);


Member Function Documentation

virtual bool operator() ( CGrid grid,
HITEM  item,
Common::CDataObject pDO 
) [pure virtual]

Called to perform some operations on items in the grid.

Parameters:
[in] grid Reference to CGrid object
[in] item Handle associated with the data object.
[in] pDO Pointer to the data object.
Returns:
False if no more iterations are needed. Otherwise true.