//
//	Class:		CDigitST
//
//	Version:	See GetVersionC() or GetVersionI()
//
//	Created:	xx-xxx-1998
//	Updated:	27-May-2004
//				29-Sep-2015
//				18-Dec-2017
//				22-Dec-2017
//				09-Nov-2020
//
//	Author:		Davide Calabro'		info@softechsoftware.it
//									http://www.softechsoftware.it
//
//	Disclaimer
//	----------
//	THIS SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT
//	ANY WARRANTIES WHETHER EXPRESSED OR IMPLIED. NO REPONSIBILITIES FOR POSSIBLE
//	DAMAGES OR EVEN FUNCTIONALITY CAN BE TAKEN. THE USER MUST ASSUME THE ENTIRE
//	RISK OF USING THIS SOFTWARE.
//
//	Terms of use
//	------------
//	In the past years SoftechSoftware has produced many free controls and code snippets.
//	All of this products were released with the full source codes included and hundreds of developers
//	all around the world have taken benefits using these easy and ready to use controls into their applications.
//	In return, SoftechSoftware asked only for a small money donation from developers.
//	Unfortunately only a very limited number of donations has been received from the large number of users
//	that rely on SoftechSoftware products for their applications.
//	Producing and updating good software costs time. So it costs money. Also, maintaning a dedicated web site
//	costs time and money.
//
//	Starting from now on almost all SoftechSoftware products will be distributed into a single general use DLL.
//	This DLL will show an annoying dialog each time your application starts. Also, this demo DLL has resource
//	and memory leaks that make your target application unstable. You can use the demo DLL only for testing
//	the SoftechSoftware product you are interested in. Then if you decide to use this product into your
//	application you must buy the full DLL version directly from SoftechSoftware.
//
//	SoftechSoftware
//	Davide Calabro'
//	Italy
//
//	http://www.softechsoftware.it
//
#pragma once

// Uncomment following line if you are using this class outside the DLL
//#define _DIGITST_NODLL_

#ifndef _DIGITST_NODLL_
#ifndef	_SOFTECHSOFTWAREDLL_NOLIB_
	#ifdef _DEBUG
		#ifdef _UNICODE
			#ifdef	_WIN64
				#pragma comment(lib, "SoftechSoftwareUD64.lib")
			#else
				#pragma comment(lib, "SoftechSoftwareUD.lib")
			#endif
		#else
			#ifdef	_WIN64
				#pragma comment(lib, "SoftechSoftwareD64.lib")
			#else
				#pragma comment(lib, "SoftechSoftwareD.lib")
			#endif
		#endif
	#else
		#ifdef _UNICODE
			#ifdef	_WIN64
				#pragma comment(lib, "SoftechSoftwareU64.lib")
			#else
				#pragma comment(lib, "SoftechSoftwareU.lib")
			#endif
		#else
			#ifdef	_WIN64
				#pragma comment(lib, "SoftechSoftware64.lib")
			#else
				#pragma comment(lib, "SoftechSoftware.lib")
			#endif
		#endif
	#endif
#endif

	#ifdef	_SOFTECHSOFTWAREDLL_BUILDDLL_
		#define	DIGITST_EXPORT	__declspec(dllexport)
	#else
		#define	DIGITST_EXPORT	__declspec(dllimport)
	#endif

#else
		#define	DIGITST_EXPORT
#endif

// Min number of digits we can display
#define DIGITST_MIN_PRECISION	1
// Max number of digits we can display (it can be increased)
#define DIGITST_MAX_PRECISION	10
// Number of supported chars
#define DIGITST_LEN_CHARSET		23
// Space left around the bitmap for border
#define DIGITST_BORDER_SPACE	0

// MSDN KB Article: 134980
// PRB: C4251 & C4275 Compiler Warnings While Compiling an AFXDLL
#pragma warning(disable: 4275)
#pragma warning(disable: 4251)

class DIGITST_EXPORT CDigitST : public CStatic
{
public:
	CDigitST();
	virtual ~CDigitST();

    enum {	DIGITST_LEFT		= 0x01, 
			DIGITST_TOP			= 0x02,
			DIGITST_RIGHT		= 0x04,
			DIGITST_BOTTOM		= 0x08};

public:

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CDigitST)
	//}}AFX_VIRTUAL

public:
	void SetAutoResize(BOOL bAutoResize = TRUE);
	BOOL GetAutoResize();

	void SetText(LPCTSTR szpText, BOOL bRepaint = TRUE);
	void SetText(int nValue, int nBase = 10, BOOL bRepaint = TRUE);
	void SetText(long lValue, int nBase = 10, BOOL bRepaint = TRUE);
	
	BOOL SetStyle(UINT nBitmapId, int nPrecision);

	void SetPrecision(int nPrecision, BOOL bResize = TRUE);
	int GetPrecision();

	void SetResize(DWORD dwResize, BOOL bResize = TRUE);
	DWORD GetResize();

	void SetZeroPadding(BOOL bPad = FALSE, BOOL bRepaint = TRUE);
	BOOL GetZeroPadding();

	static short GetVersionI()		{return 24;}
	static LPCTSTR GetVersionC()	{return (LPCTSTR)_T("2.4");}

protected:
	//{{AFX_MSG(CDigitST)
	afx_msg void OnPaint();
	//}}AFX_MSG

private:
	void Resize();
	void DrawDigits(CDC* pDC);

	TCHAR m_szText[DIGITST_MAX_PRECISION + 1];

	CBitmap m_bmDigit;
	int m_nWidth;
	int m_nHeight;

	int m_nPrecision;

	BOOL m_bZeroPadding;
	BOOL m_bAutoResize;
	DWORD m_dwResize;

	DECLARE_MESSAGE_MAP()
};

#pragma warning(default: 4275)
#pragma warning(default: 4251)

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
