Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

The Ultimate Toolbox - Updates and User Contributions

, 12 Feb 2013
Updates and User Contributions for the Ultimate Toolbox Libraries
OutlookDemoUpdate.zip
Ultimate Grid
Demos
OutlookStyle
OutlookStyle.aps
OutlookStyle.dsp
OutlookStyle.dsw
OutlookStyle.suo
res
bitmap1.bmp
bmattach.bmp
bmp00001.bmp
bmp00002.bmp
bmp00003.bmp
Flags.bmp
OutlookStyle.ico
OutlookStyleDoc.ico
Toolbar.bmp
toolbar1.bmp
toolbar2.bmp
toolbarf.bmp
UltimateGrid72_Src_Update01.zip
CellTypes
Include
Source
UltimateGrid72_Src_Update02.zip
DataSources
ODBC
OleDB
EditControls
UltimateGrid72_Src_Update03.zip
UltimateGrid72_Src_Update04.zip
UltimateGrid73_src.zip
BuildDLL
Build DLL.dsp
Build DLL.dsw
res
BuildLib
ugmfclib.dsp
ugmfclib.dsw
Lib
Skel
UltimateTCP-IP42_Src_Update01.zip
Ultimate TCP-IP
Include
Security
Include
Source
source
UltimateTCP-IP42_Src_Update02.zip
Examples
Client
Mail
icon1.ico
icon2.ico
MailClientS.suo
test.dsp
test.dsw
UltimateTCP-IP42_Src_Update03.zip
ultimatetoolbox93_src_update01.zip
Ultimate Toolbox
include
source
UltimateToolbox93_Src_Update02.zip
lib
Build DLLs
Build Libs
UltimateToolbox93_Src_Update03.zip
UltimateToolbox93_Src_Update04.zip
UltimateToolbox93_Src_Update05.zip
/*************************************************************************
				Class Implementation : CUGDrawHint
**************************************************************************
	Source file : UGDrwHnt.cpp
// This software along with its related components, documentation and files ("The Libraries")
// is � 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
// governed by a software license agreement ("Agreement").  Copies of the Agreement are
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
// to obtain this file, or directly from our office.  For a copy of the license governing
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
*************************************************************************/
#include "stdafx.h"
#include "UGCtrl.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/***************************************************
	Standard construction/desrtuction
***************************************************/
CUGDrawHint::CUGDrawHint()
{
	m_List					= NULL;
	m_VList					= NULL;

}

CUGDrawHint::~CUGDrawHint()
{
	ClearHints();
}

/***************************************************
AddHint
	function is called to add a single cell to the 
	redraw list.
Params:
	col, row	- coordinates of the cell to redraw
Returns:
	<none>
*****************************************************/
void CUGDrawHint::AddHint(int col,long row)
{
	AddHint(col,row,col,row);	
}

/***************************************************
AddHint
	function is called to add a block of cells to the 
	redraw list.
Params:
	startCol,	- parameters passed in indicate the 
	startRow,	  range of cells that need to be added
	endCol,		  to the redraw list.
	endRow
Returns:
	<none>
*****************************************************/
void CUGDrawHint::AddHint(int startCol,long startRow,int endCol,long endRow)
{
	
	UGDrwHintList	*next = m_List;
	UGDrwHintList	*newhint = new UGDrwHintList;
		
	if(m_List != NULL)
	{
		while(next->next != NULL)
		{
			next = next->next;
		}
		next->next = newhint;
	}
	else
	{
		m_List = newhint;
		m_minCol = startCol;
		m_minRow = startRow;
		m_maxCol = endCol;
		m_maxRow = endRow;
	}
	
	newhint->next = NULL;
	newhint->startCol = startCol;
	newhint->startRow = startRow;
	newhint->endCol = endCol;
	newhint->endRow = endRow;

	if(startCol < m_minCol)
		m_minCol = startCol;
	if(endCol > m_maxCol)
		m_maxCol = endCol;
	if(startRow < m_minRow)
		m_minRow = startRow;
	if(endRow > m_maxRow)
		m_maxRow = endRow;
}

/***************************************************
AddToHint
	function is almost identical to the AddHint with only one addition, 
	it updates the member UGDrwHintList (m_List) object to contain
	total redraw range in the head of the list.
Params:
	col, row	- coordinates of the cell to redraw
Returns:
	<none>
*****************************************************/
void CUGDrawHint::AddToHint(int col,long row)
{
		AddToHint(col,row,col,row);	
}

/***************************************************
AddToHint
	function is almost identical to the AddHint with only one addition, 
	it updates the member UGDrwHintList (m_List) object to contain
	total redraw range in the head of the list.
Params:
	startCol,	- parameters passed in indicate the 
	startRow,	  range of cells that need to be added
	endCol,		  to the redraw list.
	endRow
Returns:
	<none>
*****************************************************/
void CUGDrawHint::AddToHint(int startCol,long startRow,int endCol,long endRow)
{
	if(m_List == NULL)
		AddHint(startCol,startRow,endCol,endRow);	

	if(m_List->startCol > startCol)
		m_List->startCol = startCol;
	if(m_List->endCol < endCol)
		m_List->endCol = endCol;
	if(m_List->startRow > startRow)
		m_List->startRow = startRow;
	if(m_List->endRow < endRow)
		m_List->endRow = endRow;
}

/***************************************************
ClearHints
	function is called to remove all entries
	in the draw hint list.
Params:
	<none>
Returns:
	<none>
*****************************************************/
void CUGDrawHint::ClearHints()
{
	
	//clear the Invalid list
	UGDrwHintList	*current = m_List;
	UGDrwHintList	*next;
		
	while(current != NULL)
	{
		next = current->next;
		delete current;
		current = next;
	}
	m_List = NULL;

	//clear the valid list
	UGDrwHintVList	*currentV = m_VList;
	UGDrwHintVList	*nextV;
		
	while(currentV != NULL)
	{
		nextV = currentV->next;
		delete currentV;
		currentV = nextV;
	}
	m_VList = NULL;
}

/***************************************************
IsInvalid
	function is called to determine if a given cell
	is invalid, and has to be redrawn.
Params:
	col, row	- coordinates of a cell in question
Returns:
	TRUE		- if the cell is invalid
	FALSE		- if failed to locate the cell
*****************************************************/
BOOL CUGDrawHint::IsInvalid(int col,long row)
{
	if(m_List == NULL)
		return FALSE;

	if(col < m_minCol || col > m_maxCol)
		return FALSE;
	if(row < m_minRow || row > m_maxRow)
		return FALSE;

	UGDrwHintList	*current = m_List;

	//check the invalid list
	while(current != NULL)
	{
		//check to see if the item in the list covers a greater range
		if(col >= current->startCol && col <= current->endCol)
		{
			if(row >= current->startRow && row <= current->endRow)
			{
				return TRUE;
			}
		}		
		current = current->next;
	}	

	//if the item is not in the invalid list assume it is valid
	return FALSE;
}

/***************************************************
IsValid
	function is called to determine if a given cell
	is valid, and does not have to be redrawn.
Params:
	col, row	- coordinates of a cell in question
Returns:
	TRUE		- if the cell is valid
	FALSE		- if failed to locate the cell
*****************************************************/
BOOL CUGDrawHint::IsValid(int col,long row)
{
	if(m_VList == NULL)
		return FALSE;

	UGDrwHintVList	*currentV = m_VList;
	UGDrwHintVList	*nextV;
		
	//check the valid list
	while(currentV != NULL)
	{
		nextV = currentV->next;
		if(col == currentV->Col && row == currentV->Row)
			return TRUE;
		currentV = nextV;
	}
	return FALSE;
}

/***************************************************
GetTotalRange
	function is called to retrieve the total redraw
	range.
Params:
	startCol,	- parameters passed in are used to
	startRow,	  return the entire range of cells to
	endCol,		  redraw.
	endRow
Returns:
	FALSE		- if the list is empty
	TRUE		- on success
*****************************************************/
int CUGDrawHint::GetTotalRange(int *startCol,long *startRow,int *endCol,long *endRow)
{
	if(m_List == NULL)
	{
		*startCol = 0;	//put in def values just in case the return
		*startRow = 0;	//value is not checked
		*endCol = 0;
		*endRow = 0;
		return FALSE;
	}

	*startCol = m_List->startCol;
	*startRow = m_List->startRow;
	*endCol = m_List->endCol;
	*endRow = m_List->endRow;

	UGDrwHintList	*current = m_List;
	UGDrwHintList	*next;
		
	while(current != NULL)
	{
		next = current->next;
	
		//check to see if the item in the list covers a greater range
		if(*startCol > current->startCol)
			*startCol = current->startCol;
		if(*startRow > current->startRow)
			*startRow = current->startRow;
		if(*endCol < current->endCol)
			*endCol = current->endCol;
		if(*endRow < current->endRow)
			*endRow = current->endRow;
		
		current = next;
	}
	
	return TRUE;
}

/***************************************************
SetAsValid
	function is called to validate a cell.
Params:
	col, row	- coordinates of a cell to validate
Returns:
	<none>
*****************************************************/
void CUGDrawHint::SetAsValid(int col,long row)
{
	UGDrwHintVList	*nextV = m_VList;
	UGDrwHintVList	*newhintV = new UGDrwHintVList;
		
	if(m_VList != NULL)
	{
		while(nextV->next != NULL)
		{
			nextV = nextV->next;
		}
		nextV->next = newhintV;
	}
	else
		m_VList = newhintV;
	
	newhintV->next = NULL;
	newhintV->Col = col;
	newhintV->Row = row;
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

The Ultimate Toolbox
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.
 
Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
Group type: Organisation

379 members


| Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 13 Feb 2013
Article Copyright 2008 by The Ultimate Toolbox
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid