www.pudn.com > student_system.rar > HBar.cpp


// HBar.cpp: implementation of the CHBar class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "HBar.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
 
CHBar::CHBar(int count,int minw,int maxw,int minh,int maxh,int maxy) 
{ 
	if(count<0) 
	{ 
		m_Count = 0; 
	} 
	m_Index	=	-1; 
	m_MinW	=	minw; 
	m_MaxW	=	maxw; 
	m_MinH	=	minh; 
	m_MaxH	=	maxh; 
	m_MaxY	=	maxy; 
	int ii	=	count; 
	m_IW	=	float(maxw-minw)/ii; 
	m_IH	=	float(maxh-minh)/ii; 
	m_IY	=	float(maxy)/ii; 
	m_x		=	0; 
} 
 
CHBar::~CHBar() 
{ 
 
} 
 
bool CHBar::Get(int index, int x) 
{ 
	if(index == m_Index) 
	{ 
	//	return false; 
	} 
	if(index <0) 
	{ 
		m_w = (m_MaxW+m_MinW)/2; 
		m_h = (m_MaxH+m_MinH)/2; 
		m_y = 0; 
		m_x	= (m_MaxW)*(x)+ (m_MaxW-m_w)/2; 
		return true; 
	} 
	m_Index = index; 
 
	int ii	=	abs(x - m_Index); 
	m_w		=	m_MaxW - int(ii*m_IW); 
	if(m_w