Click here to Skip to main content
15,896,118 members
Articles / Desktop Programming / ATL

CM_ConfigBuilder 1.2g: Visual Studio 6/Visual Studio 2005/Visual Studio 2008 Code Generator for Application Settings Graphic Management

Rate me:
Please Sign up or sign in to vote.
4.94/5 (126 votes)
12 Feb 2008CPOL17 min read 698.2K   9.8K   262  
CM_ConfigBuilder generates and compiles the required files to manage your application's settings/preferences and to store/retrieve them in XML format.
// AsBinaryWildCardCell.cpp: implementation for the CAsBinaryWildCard class.
//
//////////////////////////////////////////////////////////////////////


#include "stdafx.h"
#include "AsBinaryWildCardsCell.h"
#include "DrawUtils.h"
#include "resource.h"

#define BIT_SIZE			16
#define CHK_LEFT_BORDER		6
#define CHK_TOP_BORDER		2

CAsBinaryWildCardsCell::CAsBinaryWildCardsCell():
	readOnly_(false),
	bitCount_(8)
{
}

CAsBinaryWildCardsCell::~CAsBinaryWildCardsCell()
{}

void CAsBinaryWildCardsCell::SetDrawArea(const CRect& drawArea)
{
	if (!visible_)
		return;

	CRect tmp;

	tmp = drawArea;
	
	if (tmp.Height() < 2 * CHK_TOP_BORDER + BIT_SIZE)
		tmp.bottom = tmp.top + 2 * CHK_TOP_BORDER + BIT_SIZE;

	if (tmp.Width() < 2 * CHK_LEFT_BORDER + BIT_SIZE)
		tmp.right = tmp.left + 2 * CHK_LEFT_BORDER + BIT_SIZE;
	
	// calculate draw area for each bit
	//
	bitRect_.clear();

	tmp.left = drawArea.left;
	tmp.top = drawArea.top;
	tmp.bottom = drawArea.bottom;
	for (int i = 0; i < bitCount_; i++) {
		tmp.right = tmp.left + BIT_SIZE;

		bitRect_.push_back(tmp);

		tmp.OffsetRect(BIT_SIZE + 1, 0);
	}	
	
	CAsBaseCell::SetDrawArea(tmp);
}

CSize CAsBinaryWildCardsCell::GetMinSize()
{
	CSize minSize;

	minSize.cx = 2 * CHK_LEFT_BORDER + (BIT_SIZE + 1) * bitCount_;
	minSize.cy = 2 * CHK_TOP_BORDER + BIT_SIZE;

	return minSize;
}

void CAsBinaryWildCardsCell::Draw(CDC* pDC)
{
	if (!visible_ || IsHidden())
		return;

	CAsBaseCell::Draw(pDC);

	CFont* font;

	font = fontInfo_.CreateFont();
	
	for (int i = 0; i < bitRect_.size(); i++) {
		DrawUtils::DrawGradient(pDC, bitRect_[i], RGB(255,0,0), RGB(100,100,100), .5);
	}

	fontInfo_.ReleaseFont();
}

bool CAsBinaryWildCardsCell::HitTest(const CPoint& pt)
{
	return CAsBaseCell::HitTest(pt);
}

bool CAsBinaryWildCardsCell::ProcessMessage(DWORD msg, DWORD lParam, DWORD wParam, const CPoint& pt, const CRect& parentRect, bool& needRedraw)
{
	CAsBaseCell::ProcessMessage(msg, lParam, wParam, pt, parentRect, needRedraw);

	/*
	if (msg == WM_LBUTTONUP && iconRect_.PtInRect(pt) && !readOnly_) {
		SetChecked(!checked_);
	}
	*/

	return false;
}

void CAsBinaryWildCardsCell::KillFocus(bool storeData, bool redraw)
{
	CAsBaseCell::KillFocus(storeData, redraw);
}

void CAsBinaryWildCardsCell::SetFocus(bool redraw)
{
	CAsBaseCell::SetFocus(redraw);
}

void CAsBinaryWildCardsCell::SetReadOnly(bool readOnly)
{
	readOnly_ = readOnly;
}

bool CAsBinaryWildCardsCell::IsReadOnly() const
{
	return readOnly_;
}

void CAsBinaryWildCardsCell::SetBitCount(long bitCount)
{
	bitCount_ = bitCount;
}

long CAsBinaryWildCardsCell::GetBitCount() const
{
	return bitCount_;
}

void CAsBinaryWildCardsCell::SetBitStatus(long bitIndex, enBitStatus status, bool redraw)
{
	if (bitIndex < 0 || bitIndex >= bitCount_)
		return;

	bitStatus_[bitIndex] = status;

	if (redraw)
		parentWnd_->RedrawWindow(drawArea_);
}

CAsBinaryWildCardsCell::enBitStatus CAsBinaryWildCardsCell::GetBitStatus(long bitIndex) const
{
	if (bitIndex < 0 || bitIndex >= bitCount_)
		return enBitStatus_Unchecked;

	return bitStatus_[bitIndex];
}

void CAsBinaryWildCardsCell::SetBinaryString(const string& checkedText, bool redraw)
{

}

string CAsBinaryWildCardsCell::GetBinaryString() const
{
	return binaryString_;
}

void CAsBinaryWildCardsCell::SetValue(long value, bool redraw)
{

}

long CAsBinaryWildCardsCell::GetValue() const
{
	return value_;
}

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)


Written By
Web Developer
Italy Italy
For all Stefano's latest code, binaries and tutorials visit www.codemachines.com

Comments and Discussions