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 CPOL
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 Declaration : CUGDataSource
**************************************************************************
	Source file : UGDtaSrc.cpp
	Header file : UGDtaSrc.h
// 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.

	Purpose
		The CUGDataSource class is used by the grid
		as standard interface between the grid
		and its data.  The Ultimate Grid relies
		on CUGDataSource derived class to provide
		it with all of the information that needs
		to be displayed.

		Datasources can be practically anything
		i.e.	arrays
				linked lists
				databases
				flat files
				real-time feeds (sensors)
				calculations

	Details
		This is a base class which all other datasources
		must be derived from. By defining a standard
		interface to the data, an abstract layer is
		created which allows the uderlying data to
		come from any source, plus allows the datasource
		to be changed without any code re-write.

		At the minimum only ONE virtual function must
		be overwitten it is the GetCell. GetCell is
		called by the grid when it needs information
		about a particular cell.

		Even though the grid generally works on a cell by
		cell basis, many datasource (such as databases) 
		tend to work on a row by row basis. To allow data
		to be written to the datasource in this manner
		transaction writing can be used within a datasource
		by overwritting the transaction functions.

		If a derived datasource cannot return the number
		of rows that is contains, then overwrite
		the OnHitBottom virtual function. This allows for
		the grid to ask the datasource for new rows on the fly.

		Stanard return values from a datasource are
			UG_NA		- not implemented (-1)
			UG_SUCCESS	- success (0)
			1 and up	- error codes
*************************************************************************/
#ifndef _UGDtaSrc_H_
#define _UGDtaSrc_H_

//defines for the IsSupported function
#define UGDS_SUPPORT_INSERTROW		BIT0
#define UGDS_SUPPORT_APPENDROW		BIT1
#define UGDS_SUPPORT_INSERTCOL		BIT2
#define UGDS_SUPPORT_APPENDCOL		BIT3
#define UGDS_SUPPORT_DELETEROW		BIT4
#define UGDS_SUPPORT_DELETECOL		BIT5
#define UGDS_SUPPORT_EMPTY			BIT6
#define UGDS_SUPPORT_CLOSE			BIT7
#define UGDS_SUPPORT_SAVE			BIT8
#define UGDS_SUPPORT_OPEN			BIT9
#define UGDS_SUPPORT_SETPASSWORD	BIT10
#define UGDS_SUPPORT_FIND			BIT11
#define UGDS_SUPPORT_SORT			BIT12
#define UGDS_SUPPORT_GETNUMROWS		BIT13
#define UGDS_SUPPORT_GETNUMCOLS		BIT14
#define UGDS_SUPPORT_GETCOLNAME		BIT15
#define UGDS_SUPPORT_GETCOLTYPE		BIT16
#define UGDS_SUPPORT_SETCELL		BIT17
#define UGDS_SUPPORT_GETCELL		BIT18
#define UGDS_SUPPORT_TRANSACTIONS	BIT19
#define UGDS_SUPPORT_HITBOTTON		BIT20
#define UGDS_SUPPORT_HITTOP			BIT21
#define UGDS_SUPPORT_GETPREVCOL		BIT22

class UG_CLASS_DECL CUGDataSource
{
protected:
	friend CUGCtrl;
	CUGCtrl * m_ctrl;  //pointer to the main class
	
	long m_ID;

public:
	CUGDataSource();
	virtual ~CUGDataSource();

	void SetID(long ID);
	long GetID();
	
	//opening and closing
	virtual int Open(LPCTSTR name,LPCTSTR option);
	virtual BOOL IsOpen();
	virtual int SetPassword(LPCTSTR user,LPCTSTR pass);
	
	virtual int Close();
	virtual int Save();
	virtual int SaveAs(LPCTSTR name,LPCTSTR option);

	//row and col info
	virtual long GetNumRows();
	
	virtual int GetNumCols();
	virtual int GetColName(int col,CString * string);
	virtual int GetColType(int col,int *type);	//0-string 1-bool 2-short 3-long 4-float 
												//5-double 6-currency 7-data 8-time
												//8-memo 9-blob 10-ole
	virtual int GetColFromName(LPCTSTR name,int *col);
	
	//add-update-clear
	virtual int AppendRow();
	virtual int AppendRow(CUGCell **cellList,int numCells);
	virtual int InsertRow(long row);
	virtual int AppendCol();
	virtual int InsertCol(int col);
	virtual int DeleteRow(long row);
	virtual int DeleteCol(int col);
	virtual int DeleteCell(int col,long row);
	virtual int Empty();

	//cell info
	virtual int	GetCell(int col,long row,CUGCell *cell);
	virtual int	SetCell(int col,long row,CUGCell *cell);

	//finding sorting
	virtual int FindFirst(CString *string,int *col,long *row,long flags);
	virtual int FindNext(CString *string,int *col,long *row,int flags);

	virtual int SortBy(int col,int flags);
	virtual int SortBy(int *cols,int num,int flags);

	//options
	virtual int SetOption(int option,long param1,long param2);
	virtual int GetOption(int option,long& param1,long& param2);

	//movement 
	virtual int OnHitTop(long numrows,long rowspast,long *rowsfound);
	virtual int OnHitBottom(long numrows,long rowspast,long *rowsfound);

	//grid movement
	virtual void OnRowChange(long oldRow,long newRow);
	virtual void OnColChange(int oldCol,int newCol);
	virtual int OnCanMove(int oldcol,long oldrow,int newcol,long newrow);

	//used to check to see if the data source supports a standard function
	BOOL IsFunctionSupported(long type);

	//transactions
	virtual int StartTransaction();
	virtual int CancelTransaction();
	virtual int FinishTransaction();

	// editing notifications...
	virtual int OnEditStart(int col, long row,CWnd **edit);
	virtual int OnEditVerify(int col,long row,CWnd *edit,UINT *vcKey);
	virtual int OnEditFinish(int col, long row,CWnd *edit,LPCTSTR string,BOOL cancelFlag);
	virtual int OnEditContinue(int oldcol,long oldrow,int* newcol,long* newrow);

	//other functions
	virtual int GetPrevNonBlankCol(int *col,long row);
};

#endif // _UGDtaSrc_H_

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

387 members


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