⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 buttomunit.cpp

📁 对测井数据显示、编辑、处理
💻 CPP
字号:
// ButtomUnit.cpp: implementation of the CButtomUnit class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "welldataprocess.h"
#include "ButtomUnit.h"

#include "GlobalData.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CButtomUnit::CButtomUnit()
{
	m_color = RGB(233, 216, 192);
	m_strName = " ";

}
CButtomUnit::CButtomUnit(COLORREF color, CRect rect, CString strName)
{
	m_color = color;
	m_rect = rect;
	m_strName = strName;
}

CButtomUnit::~CButtomUnit()
{

}
void CButtomUnit::SetColor(COLORREF color)
{
	m_color = color;
}

void CButtomUnit::SetRectValue(CRect rect)
{
	m_rect = rect;	
}

void CButtomUnit::SetTopPosition(int nTopPos)
{
	m_rect.top = nTopPos;
}

void CButtomUnit::SetBottomPosition(int nBottomPos)
{
	m_rect.bottom = nBottomPos;
}

CRect CButtomUnit::GetLayerRect()
{
	return m_rect;
}

COLORREF CButtomUnit::GetLayerColor()
{
	return m_color;
}

int CButtomUnit::GetTopPosition()
{
	return m_rect.top;
}

int CButtomUnit::GetBottomPosition()
{
	return m_rect.bottom ;
}

BOOL CButtomUnit::HitTest(CPoint point)
{
	int x = point.x;
	int y = point.y;
	int x0 = m_rect.left;
	int y0 = m_rect.top + 3;
	int x1 = m_rect.right;
	int y1 = m_rect.bottom - 3;
	if (x < x1 && x > x0 && y < y1 && y > y0)
	{	
		m_bSelect = TRUE;
		return TRUE;
	}
	m_bSelect = FALSE;
	return FALSE;
}

void CButtomUnit::Draw(CDC *pDC)
{
	COLORREF color;
	if(m_bSelect)
		color = RGB(120, 200, 200);
	else
		color = m_color;

	EraseRect(pDC, m_rect, color);

	int x = m_rect.left + m_rect.Width() / 2;
	int y = m_rect.top + m_rect.Height() / 2;
	PutText(TRUE, x, y, 14, 0, m_strName, pDC);
}

CButtomUnit::operator=(const CButtomUnit& other)
{
	m_rect = other.m_rect;
	m_color = other.m_color;
	m_bSelect = other.m_bSelect;
}

CString CButtomUnit::GetStrName()
{
	return m_strName;
}

void CButtomUnit::SetStrName(CString strName)
{
	m_strName = strName;	
}


void CButtomUnit::SetRoad(CRoadUnit* pRoadUnit)
{
	m_rect.top = pRoadUnit->GetOrgPoint().y + 4;
	m_rect.bottom = pRoadUnit->GetRoadHeadHeight() / 2 + m_rect.top - 8;
	m_rect.left = pRoadUnit->GetOrgPoint().x + 4;
	m_rect.right = m_rect.left + pRoadUnit->GetRoadWidth() - 8;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -