|
/*****************************************************************************
COPYRIGHT (C) 2000, Ken Bertelson <kenbertelson@hotmail.com>
*****************************************************************************/
#if !defined(AFX_TREECOLUMN_H__55D4E2A3_EDF9_11D3_B75E_00C04F6A7AE6__INCLUDED_)
#define AFX_TREECOLUMN_H__55D4E2A3_EDF9_11D3_B75E_00C04F6A7AE6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "..\GRIDCTRL_SRC\GridCtrl.h"
class CTreeColumn
{
public:
CTreeColumn();
virtual ~CTreeColumn();
// accessors
public:
virtual void SetFormat(DWORD nFormat) { m_nFormat = nFormat; }
virtual DWORD GetFormat() const { return m_nFormat; }
virtual void SetBkClr(COLORREF crBkClr) { m_crBkClr = crBkClr; }
virtual COLORREF GetBkClr() const { return m_crBkClr; }
virtual void SetFgClr(COLORREF crFgClr) { m_crFgClr = crFgClr; }
virtual COLORREF GetFgClr() const { return m_crFgClr; }
virtual void SetParam(LPARAM lParam) { m_lParam = lParam; }
virtual LPARAM GetParam() const { return m_lParam; }
virtual void SetFont(const LOGFONT* plf)
{
// One Tree Column will serve multiple cells, so setting fonts can be tricky
// since there is wonderful scope for overwriting one's self. Let's be cautious.
if (plf == NULL)
{
delete m_plfFont;
m_plfFont = NULL;
}
else
{
static LOGFONT lf;
memcpy(&lf, plf, sizeof(LOGFONT));
if (!m_plfFont)
m_plfFont = new LOGFONT;
if (m_plfFont)
memcpy(m_plfFont, &lf, sizeof(LOGFONT));
}
}
virtual LOGFONT* GetFont() const
{
if (m_plfFont)
return (LOGFONT*) m_plfFont;
else
return GetGrid()->GetDefaultCell(FALSE, FALSE)->GetFont();
}
virtual void SetAllowDraw(BOOL bAllowDraw) { m_bAllowDraw = bAllowDraw; }
virtual BOOL GetAllowDraw() const { return m_bAllowDraw; }
virtual void SetEditWnd(CWnd* pEditWnd) { m_pEditWnd = pEditWnd; }
virtual CWnd* GetEditWnd() const const { return m_pEditWnd; }
virtual void SetGrid(CGridCtrl* pGrid) { m_pGrid = pGrid; }
virtual CGridCtrl* GetGrid() const { return m_pGrid; }
virtual void SetColumnWithTree( int iColumnWithTree) { m_iColumnWithTree = iColumnWithTree; }
virtual int GetColumnWithTree() const { return m_iColumnWithTree; }
virtual void SetDefTreeIndent( int nDefTreeIndent) { m_nDefTreeIndent = nDefTreeIndent; }
virtual int GetDefTreeIndent() const { return m_nDefTreeIndent; }
virtual void SetFixedRowCount( int iFixedRowCount) { m_iFixedRowCount = iFixedRowCount; }
virtual int GetFixedRowCount() const { return m_iFixedRowCount; }
virtual void SetRowCount( int iRowCount) { m_iRowCount = iRowCount; }
virtual int GetRowCount() const { return m_iRowCount; }
// tree column operations
public:
BOOL TreeSetup( CGridCtrl* apGridCtrl, // tree acts on a column in this grid
int aiColumn, // which column has tree
int aiTotalRows, // total number of rows if tree totally expanded
int aiFixedRowCount,// Set fixed row count now, too
const unsigned char* apucTreeLevelAry, // Tree Level data array --
// must have aiTotalRows of entries
BOOL abShowTreeLines, // T=show tree (not grid) lines; F=no tree lines
BOOL abUseImages, // T=use 1st 3 images from already set image list
// to display folder graphics
CRuntimeClass* apRuntimeClass = NULL);
// can use your special
// CGridTreeCellBase-derived class
// returns: success / fail
void SetTreeUsesImages( BOOL abUseImages); // T=use images
BOOL GetTreeUsesImages() const { return m_bTreeUsesImages; }
int GetTreeUsesNbrImages() const;
void SetTreeLines( BOOL abShowTreeLines); // T=show tree lines
BOOL GetTreeLines() const { return m_bShowTreeLines; }
void SetTreeLineColor(COLORREF clr) { m_crTreeLineColour = clr; }
COLORREF GetTreeLineColor() const { return m_crTreeLineColour; }
unsigned char GetTreeLevel( int aiRow); // row
// returns: tree level, =0 if invalid input
BOOL IsTreeRowDisplayed( int aiRow); // row
// returns: T=tree row is displayed
unsigned char GetLevelAndHide( int aiRow); // row
void TreeRefreshRows();
void TreeDataPrepOutline(unsigned char aucLevel, // level to display >= 0x80 displays all
int aiIndex, // Index to tree display data to modify
int aiNbrElements); // nbr of elements in tree display data
void TreeDisplayOutline( unsigned char aucLevel ); // level to display >= 0x80 displays all
void TreeDataExpandOneLevel( int aiGridRow);
void TreeDataCollapseAllSubLevels( int aiGridRow);
void TreeExpandCollapseToggle( int aiGridRow); // Grid row of node to toggle
BOOL TreeCellHasPlusMinus( int aiRow, // row of Cell to check
BOOL* apbIsPlus, // returns: T=Is a plus
BOOL* apbIsMinus, // returns: T=Is a minus
BOOL* apbIsLastLeaf);// returns: T=Is Last Leaf
// returns: T=cell has a plus or minus; F=not
virtual BOOL IsDefaultFont() const { return (m_plfFont == NULL); }
// let the CGridTreeCtrl maintain a single instance of the following
// on the behalf of the expected column of CGridTreeCell's
protected:
DWORD m_nFormat; // Cell format
COLORREF m_crBkClr; // Background colour (or CLR_DEFAULT)
COLORREF m_crFgClr; // Forground colour (or CLR_DEFAULT)
LPARAM m_lParam; // 32-bit value to associate with item
LOGFONT *m_plfFont; // Cell font
BOOL m_bAllowDraw; // private switch to turn off / on drawing
CWnd* m_pEditWnd; // can edit only 1 at a time
CGridCtrl* m_pGrid;
// tree column properties
int m_iColumnWithTree;
int m_nDefTreeIndent;
BOOL m_bShowTreeLines;
BOOL m_bTreeUsesImages;
COLORREF m_crTreeLineColour;
int m_iFixedRowCount;
int m_iRowCount;
};
#endif // !defined(AFX_TREECOLUMN_H__55D4E2A3_EDF9_11D3_B75E_00C04F6A7AE6__INCLUDED_)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.