bool CSelection::IsColumnSelected(int Column, int Channel) const
{
	int SelColStart = GetColStart();
	int SelColEnd	= GetColEnd();

	if (Channel > GetChanStart() && Channel < GetChanEnd())
		return true;

	// 0 = Note (0)
	// 1, 2 = Instrument (1)
	// 3 = Volume (2)
	// 4, 5, 6 = Effect 1 (3)
	// 7, 8, 9 = Effect 1 (4)
	// 10, 11, 12 = Effect 1 (5)
	// 13, 14, 15 = Effect 1 (6)

	int SelStart = CPatternEditor::GetSelectColumn(SelColStart);
	int SelEnd = CPatternEditor::GetSelectColumn(SelColEnd);
	
	if (Channel == GetChanStart() && Channel == GetChanEnd()) {
		if (Column >= SelStart && Column <= SelEnd)
			return true;
	}
	else if (Channel == GetChanStart()) {
		if (Column >= SelStart)
			return true;
	}
	else if (Channel == GetChanEnd()) {
		if (Column <= SelEnd)
			return true;
	}

	return false;
}
bool CSelection::IsColumnSelected(column_t Column, int Channel) const
{
	column_t SelStart = GetSelectColumn(GetColStart());		// // //
	column_t SelEnd = GetSelectColumn(GetColEnd());

	return (Channel > GetChanStart() || (Channel == GetChanStart() && Column >= SelStart))		// // //
		&& (Channel < GetChanEnd() || (Channel == GetChanEnd() && Column <= SelEnd));
}
bool CSelection::IsSameStartPoint(const CSelection &selection) const
{
	return GetChanStart() == selection.GetChanStart() &&
		GetRowStart() == selection.GetRowStart() &&
		GetColStart() == selection.GetColStart() &&
		GetFrameStart() == selection.GetFrameStart();		// // //
}
bool CSelection::IsWithin(const CCursorPos &pos) const 
{
	if (pos.m_iRow >= GetRowStart() && pos.m_iRow <= GetRowEnd()) {
		if (pos.m_iChannel == GetChanStart() && pos.m_iChannel == GetChanEnd()) {
			return (pos.m_iColumn >= GetColStart() && pos.m_iColumn <= GetColEnd());
		}
		else if (pos.m_iChannel == GetChanStart() && pos.m_iChannel != GetChanEnd()) {
			return (pos.m_iColumn >= GetColStart());
		}
		else if (pos.m_iChannel == GetChanEnd() && pos.m_iChannel != GetChanStart()) {
			return (pos.m_iColumn <= GetColEnd());
		}
		else if (pos.m_iChannel >= GetChanStart() && pos.m_iChannel < GetChanEnd()) {
			return true;
		}
	}
	return false;
}
void CFrameSelection::Normalize(CFrameCursorPos &Begin, CFrameCursorPos &End) const
{
	CFrameCursorPos Temp {GetFrameStart(), GetChanStart()};
	std::swap(End, CFrameCursorPos {GetFrameEnd(), GetChanEnd()});
	std::swap(Begin, Temp);
}
void CSelection::Normalize(CCursorPos &Begin, CCursorPos &End) const		// // //
{
	CCursorPos Temp {GetRowStart(), GetChanStart(), GetColStart(), GetFrameStart()};
	std::swap(End, CCursorPos {GetRowEnd(), GetChanEnd(), GetColEnd(), GetFrameEnd()});
	std::swap(Begin, Temp);
}