// CompassCtl.cpp : Implementation of the CCompassCtrl ActiveX Control class.

#include "stdafx.h"
#include "Compass.h"
#include "CompassCtl.h"
#include "CompassPpg.h"

#include <math.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define PI 3.14159265358979323846
#define R2D 180./PI;
#define D2R PI/180.;

static const FONTDESC _fontdescDirection =
  { sizeof(FONTDESC), OLESTR("MS Sans Serif"), FONTSIZE( 12 ), FW_BOLD, 
     ANSI_CHARSET, FALSE, FALSE, FALSE };

IMPLEMENT_DYNCREATE(CCompassCtrl, COleControl)


/////////////////////////////////////////////////////////////////////////////
// Message map

BEGIN_MESSAGE_MAP(CCompassCtrl, COleControl)
	//{{AFX_MSG_MAP(CCompassCtrl)
	// NOTE - ClassWizard will add and remove message map entries
	//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG_MAP
	ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// Dispatch map

BEGIN_DISPATCH_MAP(CCompassCtrl, COleControl)
	//{{AFX_DISPATCH_MAP(CCompassCtrl)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "Heading", m_heading, OnHeadingChanged, VT_R8)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "CircleShape", m_circleShape, OnCircleShapeChanged, VT_BOOL)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "OuterRingColor", m_outerRingColor, OnOuterRingColorChanged, VT_COLOR)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "CompassColor", m_compassColor, OnCompassColorChanged, VT_COLOR)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "GridColor", m_gridColor, OnGridColorChanged, VT_COLOR)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "OuterRingWidth", m_outerRingWidth, OnOuterRingWidthChanged, VT_I2)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "MajorGridWidth", m_majorGridWidth, OnMajorGridWidthChanged, VT_I2)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "MinorGridWidth", m_minorGridWidth, OnMinorGridWidthChanged, VT_I2)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "MajorGridIncrement", m_majorGridIncrement, OnMajorGridIncrementChanged, VT_R8)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "MinorGridIncrement", m_minorGridIncrement, OnMinorGridIncrementChanged, VT_R8)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "TextColor", m_textColor, OnTextColorChanged, VT_COLOR)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "VehicleWidth", m_vehicleWidth, OnVehicleWidthChanged, VT_I2)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "VehicleColor", m_vehicleColor, OnVehicleColorChanged, VT_COLOR)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "TailconeColor", m_tailconeColor, OnTailconeColorChanged, VT_COLOR)
	DISP_PROPERTY_NOTIFY(CCompassCtrl, "ReferenceMarkColor", m_referenceMarkColor, OnReferenceMarkColorChanged, VT_COLOR)
	DISP_PROPERTY_EX(CCompassCtrl, "DirectionFont", GetDirectionFont, SetDirectionFont, VT_FONT)
	DISP_STOCKPROP_BACKCOLOR()
	DISP_STOCKPROP_CAPTION()
	DISP_STOCKPROP_FORECOLOR()
	DISP_STOCKPROP_FONT()
	//}}AFX_DISPATCH_MAP
	DISP_FUNCTION_ID(CCompassCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()


/////////////////////////////////////////////////////////////////////////////
// Event map

BEGIN_EVENT_MAP(CCompassCtrl, COleControl)
	//{{AFX_EVENT_MAP(CCompassCtrl)
	// NOTE - ClassWizard will add and remove event map entries
	//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_EVENT_MAP
END_EVENT_MAP()


/////////////////////////////////////////////////////////////////////////////
// Property pages

// TODO: Add more property pages as needed.  Remember to increase the count!
BEGIN_PROPPAGEIDS(CCompassCtrl, 3)
	PROPPAGEID(CCompassPropPage::guid)
    PROPPAGEID(CLSID_CColorPropPage)
    PROPPAGEID(CLSID_CFontPropPage)
END_PROPPAGEIDS(CCompassCtrl)


/////////////////////////////////////////////////////////////////////////////
// Initialize class factory and guid

IMPLEMENT_OLECREATE_EX(CCompassCtrl, "COMPASS.CompassCtrl.1",
	0x4621f439, 0xf150, 0x4b5f, 0x8a, 0x26, 0xa2, 0xeb, 0x85, 0xb4, 0x86, 0x1b)


/////////////////////////////////////////////////////////////////////////////
// Type library ID and version

IMPLEMENT_OLETYPELIB(CCompassCtrl, _tlid, _wVerMajor, _wVerMinor)


/////////////////////////////////////////////////////////////////////////////
// Interface IDs

const IID BASED_CODE IID_DCompass =
		{ 0x7dda1a11, 0x7501, 0x44d7, { 0xaf, 0x8f, 0x9d, 0x3c, 0xba, 0xbd, 0x1d, 0xa1 } };
const IID BASED_CODE IID_DCompassEvents =
		{ 0xfe5a1e41, 0xc6b7, 0x4a9d, { 0xb7, 0x4a, 0x8, 0xbe, 0x1e, 0x3a, 0xb7, 0xc7 } };


/////////////////////////////////////////////////////////////////////////////
// Control type information

static const DWORD BASED_CODE _dwCompassOleMisc =
	OLEMISC_ACTIVATEWHENVISIBLE |
	OLEMISC_SETCLIENTSITEFIRST |
	OLEMISC_INSIDEOUT |
	OLEMISC_CANTLINKINSIDE |
	OLEMISC_RECOMPOSEONRESIZE;

IMPLEMENT_OLECTLTYPE(CCompassCtrl, IDS_COMPASS, _dwCompassOleMisc)


/////////////////////////////////////////////////////////////////////////////
// CCompassCtrl::CCompassCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CCompassCtrl

BOOL CCompassCtrl::CCompassCtrlFactory::UpdateRegistry(BOOL bRegister)
{
	// TODO: Verify that your control follows apartment-model threading rules.
	// Refer to MFC TechNote 64 for more information.
	// If your control does not conform to the apartment-model rules, then
	// you must modify the code below, changing the 6th parameter from
	// afxRegApartmentThreading to 0.

	if (bRegister)
		return AfxOleRegisterControlClass(
			AfxGetInstanceHandle(),
			m_clsid,
			m_lpszProgID,
			IDS_COMPASS,
			IDB_COMPASS,
			afxRegApartmentThreading,
			_dwCompassOleMisc,
			_tlid,
			_wVerMajor,
			_wVerMinor);
	else
		return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}


/////////////////////////////////////////////////////////////////////////////
// CCompassCtrl::CCompassCtrl - Constructor

CCompassCtrl::CCompassCtrl() : m_directionFont( &m_xFontNotification )
{
	InitializeIIDs(&IID_DCompass, &IID_DCompassEvents);

	// TODO: Initialize your control's instance data here.
}


/////////////////////////////////////////////////////////////////////////////
// CCompassCtrl::~CCompassCtrl - Destructor

CCompassCtrl::~CCompassCtrl()
{
	// TODO: Cleanup your control's instance data here.
}


/////////////////////////////////////////////////////////////////////////////
// CCompassCtrl::OnDraw - Drawing function
/*
void CCompassCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	// TODO: Replace the following code with your own drawing code.
	pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
	pdc->Ellipse(rcBounds);

	if (!IsOptimizedDraw())
	{
		// The container does not support optimized drawing.

		// TODO: if you selected any GDI objects into the device context *pdc,
		//		restore the previously-selected objects here.
		//		For more information, please see MFC technical note #nnn,
		//		"Optimizing an ActiveX Control".
	}
}
*/

void CCompassCtrl::OnDraw(CDC* pdc, const CRect& rcBounds,
							 const CRect& rcInvalid)
{
    // Create a compatible DC.
    HDC hdcMem = CreateCompatibleDC(pdc->GetSafeHdc());

    // Create a bitmap big enough for client rectangle.
    HBITMAP hbmMem = CreateCompatibleBitmap(pdc->GetSafeHdc(),
		rcBounds.right-rcBounds.left, rcBounds.bottom-rcBounds.top);

    // Select the bitmap into the off-screen DC.
    HBITMAP hbmOld = (HBITMAP) SelectObject(hdcMem, hbmMem);

    // Render the image into the offscreen DC.
	CDC *pdcm = CDC::FromHandle(hdcMem);
	MyOnDraw(pdcm,rcBounds,rcInvalid);

    // Blt the changes to the screen DC.
    BitBlt(pdc->GetSafeHdc(),rcBounds.left, rcBounds.top,
           rcBounds.right-rcBounds.left, rcBounds.bottom-rcBounds.top,
           hdcMem, 0, 0, SRCCOPY);

    // Done with off-screen bitmap and DC.
    SelectObject(hdcMem, hbmOld);
    DeleteObject(hbmMem);
    DeleteDC(hdcMem);
}

void CCompassCtrl::MyOnDraw(CDC* pdc, const CRect& rcBounds,
							 const CRect& rcInvalid)
{
    CBrush* pOldBrush;
    CBrush bkBrush(TranslateColor(GetBackColor()));
    CPen* pOldPen;
    CRect rc = rcBounds;
	CRect vehicleRect = rcBounds;
	CRect tailconeRect = rcBounds;
	CFont* pOldFont;
	CPoint points[3];
    TEXTMETRIC tm;
	char label[32];
	POINT p1,p2,p3;
    
	// Set the ForeColor property color and transparent background mode into the device context
    pdc->SetTextColor(m_textColor);
    pdc->SetBkMode(TRANSPARENT);

    // Paint the background using the BackColor property
    pdc->FillRect(rcBounds, &bkBrush);

	// Get the boundary
	GetDrawRect(&rc);

	// Draw the compass
	CPen compassStroke;
	compassStroke.CreatePen(PS_SOLID, m_outerRingWidth, m_outerRingColor);
    pOldPen = (CPen*)pdc->SelectObject(&compassStroke);
	CBrush compassBrush(m_compassColor);
    pOldBrush = pdc->SelectObject(&compassBrush);
    pdc->Ellipse(rc);

	// Set the font
	pOldFont = SelectStockFont(pdc);
    pdc->GetTextMetrics(&tm);

	// Make the major grid pen
	CPen majorGridStroke;
	majorGridStroke.CreatePen(PS_SOLID, m_majorGridWidth, m_gridColor);

	// Draw the major grid
	pdc->SetTextAlign(TA_CENTER | TA_BASELINE);
	pdc->SelectObject(&majorGridStroke);
	int nTicks = MyRound(360./m_majorGridIncrement)+1;
	for (int tick=0; tick < nTicks; tick++)
	{
		double angle = tick*m_majorGridIncrement;
		GetHeadingGridEndpoints(&rc,&p1,&p2,&p3,angle-m_heading,0.7,0.85);
		pdc->MoveTo(p2);
		pdc->LineTo(p3);
		int iangle = MyRound(angle);
		SelectFontObject(pdc, m_directionFont);
		if (iangle == 0) continue;
		else if (iangle == 90) sprintf(label,"%s","E");
		else if (iangle == 180) sprintf(label,"%s","S");
		else if (iangle == 270) sprintf(label,"%s","W");
		else if (iangle == 360) sprintf(label,"%s","N");
		else {
			sprintf(label,"%d",iangle); 
			SelectStockFont(pdc);
		}
		pdc->ExtTextOut(p1.x,p1.y+tm.tmHeight/2,ETO_CLIPPED, rc, label,
			strlen(label), NULL);
	}

	// Make the minor grid pen
	CPen minorGridStroke;
	minorGridStroke.CreatePen(PS_SOLID, m_minorGridWidth, m_gridColor);
	
	// Draw the minor grid
	pdc->SelectObject(&minorGridStroke);
	nTicks = MyRound(360./m_minorGridIncrement)+1;
	for (tick=0; tick < nTicks; tick++)
	{
		double angle = tick*m_minorGridIncrement;
		GetHeadingGridEndpoints(&rc,&p1,&p2,&p3,angle-m_heading,0.,0.9);
		pdc->MoveTo(p2);
		pdc->LineTo(p3);	
	}

	// The dimensions are multiplied by radius
	double vehicleHeight = .5;
	double vehicleWidth = vehicleHeight/3.;
	double tailconeHeight = .1;
	double tailconeWidth = .25;
	int offset = MyRound(tailconeHeight*GetRadius(&rc));
	GetVehicleBounds(&rc,&vehicleRect,vehicleHeight,vehicleWidth);
	vehicleRect.top -= offset/2;
	vehicleRect.bottom -= offset/2;
	GetTailconeBounds(&rc,&tailconeRect,tailconeHeight,tailconeWidth,
		vehicleRect.bottom);


	// Draw the vehicle
	CPen vehicleStroke;
	vehicleStroke.CreatePen(PS_SOLID, m_vehicleWidth, m_vehicleColor);
	pdc->SelectObject(&vehicleStroke);
	CBrush vehicleBrush(m_vehicleColor);
	pdc->SelectObject(&vehicleBrush);
	pdc->Ellipse(vehicleRect);

	// Draw the tailcone
	CPen tailconeStroke;
	tailconeStroke.CreatePen(PS_SOLID, m_vehicleWidth, m_tailconeColor);
	pdc->SelectObject(&tailconeStroke);
	CBrush tailconeBrush(m_tailconeColor);
	pdc->SelectObject(&tailconeBrush);
	CPoint corner;
	corner.x = corner.y = 3;
	pdc->RoundRect(tailconeRect,corner);

	// Draw the heading reference
	pdc->SelectStockObject(NULL_PEN);
	CBrush referenceBrush(m_referenceMarkColor);
	pdc->SelectObject(&referenceBrush);
	GetReferencePointer(&rc,points);
	pdc->Polygon(points,3);

	// Restore the device context
    pdc->SelectObject(pOldPen);
    pdc->SelectObject(pOldBrush);
	pdc->SelectObject(pOldFont);
}

/////////////////////////////////////////////////////////////////////////////
// CCompassCtrl::DoPropExchange - Persistence support

void CCompassCtrl::DoPropExchange(CPropExchange* pPX)
{
	ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
	COleControl::DoPropExchange(pPX);

	// TODO: Call PX_ functions for each persistent custom property.
	PX_Bool(pPX, _T("CircleShape"), m_circleShape, TRUE);
	PX_Color(pPX, _T("OuterRingColor"), m_outerRingColor, RGB(255,255,0));
	PX_Color(pPX, _T("CompassColor"), m_compassColor, RGB(0,0,0));
	PX_Color(pPX, _T("GridColor"), m_gridColor, RGB(255,255,255));
	PX_Color(pPX, _T("TextColor"), m_textColor, RGB(255,255,255));
	PX_Color(pPX, _T("VehicleColor"), m_vehicleColor, RGB(255,255,0));
	PX_Color(pPX, _T("TailconeColor"), m_tailconeColor, RGB(0,0,255));
	PX_Color(pPX, _T("ReferenceMarkColor"), m_referenceMarkColor, RGB(255,0,0));
	PX_Short(pPX, _T("VehicleWidth"), m_vehicleWidth, 2);
	PX_Short(pPX, _T("OuterRingWidth"), m_outerRingWidth, 4);
	PX_Short(pPX, _T("MajorGridWidth"), m_majorGridWidth, 2);
	PX_Short(pPX, _T("MinorGridWidth"), m_minorGridWidth, 1);
	PX_Double(pPX, _T("MajorGridIncrement"), m_majorGridIncrement, 30.);
	PX_Double(pPX, _T("MinorGridIncrement"), m_minorGridIncrement, 10.);
	PX_Double(pPX, _T("Heading"), m_heading, 0.);
	PX_Font(pPX, _T("DirectionFont"), m_directionFont, &_fontdescDirection);

}


/////////////////////////////////////////////////////////////////////////////
// CCompassCtrl::GetControlFlags -
// Flags to customize MFC's implementation of ActiveX controls.
//
// For information on using these flags, please see MFC technical note
// #nnn, "Optimizing an ActiveX Control".
DWORD CCompassCtrl::GetControlFlags()
{
	DWORD dwFlags = COleControl::GetControlFlags();


	// The control will not be redrawn when making the transition
	// between the active and inactivate state.
	dwFlags |= noFlickerActivate;

	// The control can optimize its OnDraw method, by not restoring
	// the original GDI objects in the device context.
	dwFlags |= canOptimizeDraw;
	return dwFlags;
}


/////////////////////////////////////////////////////////////////////////////
// CCompassCtrl::OnResetState - Reset control to default state

void CCompassCtrl::OnResetState()
{
	COleControl::OnResetState();  // Resets defaults found in DoPropExchange

	// TODO: Reset any other control state here.
}


/////////////////////////////////////////////////////////////////////////////
// CCompassCtrl::AboutBox - Display an "About" box to the user

void CCompassCtrl::AboutBox()
{
	CDialog dlgAbout(IDD_ABOUTBOX_COMPASS);
	dlgAbout.DoModal();
}

void CCompassCtrl::GetDrawRect(CRect *rc)
{
    if (m_circleShape) {
        int cx = rc->right - rc->left;
        int cy = rc->bottom - rc->top;

        if (cx > cy) {
            rc->left += (cx - cy) / 2;
            rc->right = rc->left + cy;
			rc->top += m_outerRingWidth/2;
			rc->bottom -= m_outerRingWidth/2;
        } else {
            rc->top += (cy - cx) / 2;
            rc->bottom = rc->top + cx;
			rc->left += m_outerRingWidth/2;
			rc->right -= m_outerRingWidth/2;
        }
    }
}

void CCompassCtrl::GetVehicleBounds(CRect *rc, CRect *vehicle, double height,
									double width)
{
	POINT center;
	GetCenter(rc,&center);
	double radius = GetRadius(rc);
	vehicle->bottom = center.y+MyRound(radius*height);
	vehicle->top = center.y-MyRound(radius*height);
	vehicle->right = center.x+MyRound(radius*width);
	vehicle->left = center.x-MyRound(radius*width);
}

void CCompassCtrl::GetTailconeBounds(CRect *rc, CRect *tailcone, double height,
									double width, int offset)
{
	POINT center;
	GetCenter(rc,&center);
	double radius = GetRadius(rc);
	tailcone->top = offset;
	tailcone->bottom = tailcone->top + MyRound(radius*height);
	tailcone->right = center.x+MyRound(radius*width/2.);
	tailcone->left = center.x-MyRound(radius*width/2.);
}

void CCompassCtrl::GetHeadingGridEndpoints(CRect *rc,POINT *p1,POINT *p2,
	POINT *p3, double angle, double range1, double range2)
{
	POINT center;
	GetCenter(rc,&center);
	double radius = GetRadius(rc);
	Reckon(radius*range1,angle,&center,p1);
	Reckon(radius*range2,angle,&center,p2);
	Reckon(radius*(1.-range2),angle,p2,p3);
}

void CCompassCtrl::GetReferencePointer(CRect *rc,CPoint points[])
{
	double cx = (double) (rc->right - rc->left);
	points[0].x = rc->left + MyRound(cx/2.) - m_outerRingWidth;
	points[0].y = rc->top + m_outerRingWidth/2; 
	points[1].x = rc->left + MyRound(cx/2.) + m_outerRingWidth;
	points[1].y = rc->top + m_outerRingWidth/2;
	points[2].x = rc->left + MyRound(cx/2.);
	points[2].y = rc->top + MyRound(2.5*(double)m_outerRingWidth);
}

// Expects azimuth in compass degrees
void CCompassCtrl::Reckon(double range, double azimuth,
							 POINT *p1, POINT *p2)
{
	double radians = PI/2. - azimuth*D2R;
	p2->x = MyRound((double)p1->x + range*cos(radians));
	p2->y = MyRound((double)p1->y - range*sin(radians));
}

void CCompassCtrl::GetCenter(CRect *rc, POINT *p)
{
	p->x = MyRound((double)rc->left + (double) (rc->right - rc->left)/2.);
    p->y = MyRound((double)rc->top + (double) (rc->bottom - rc->top)/2.);
}

double CCompassCtrl::GetRadius(CRect *rc)
{
	double cx = (double) (rc->right - rc->left);
    double cy = (double) (rc->bottom - rc->top);
	return cx < cy ? cx/2. : cy/2.;
}

long int CCompassCtrl::MyRound(double num_in)
{
	double temp;
	if ( num_in < 0 ) {
		temp = num_in - ceil(num_in);
		if(temp > -0.500000)
			return (long int)floor(num_in);
		else
			return (long int)ceil(num_in);
	} else {
		temp = num_in - floor(num_in);
		if(temp > 0.500000)
			return (long int)ceil(num_in);
		else
			return (long int)floor(num_in);
	}
}

/////////////////////////////////////////////////////////////////////////////
// CCompassCtrl message handlers

void CCompassCtrl::OnHeadingChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnCircleShapeChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnOuterRingColorChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnCompassColorChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnGridColorChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnOuterRingWidthChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnMajorGridWidthChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnMinorGridWidthChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnMajorGridIncrementChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnMinorGridIncrementChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnTextColorChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

LPFONTDISP CCompassCtrl::GetDirectionFont() 
{
	// TODO: Add your property handler here
	return m_directionFont.GetFontDispatch( );
}

void CCompassCtrl::SetDirectionFont(LPFONTDISP newValue) 
{
	// TODO: Add your property handler here
    m_directionFont.InitializeFont( &_fontdescDirection, newValue);
    OnFontChanged();    //notify any changes
    SetModifiedFlag( );
}

void CCompassCtrl::OnVehicleWidthChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnVehicleColorChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnTailconeColorChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}

void CCompassCtrl::OnReferenceMarkColorChanged() 
{
	// TODO: Add notification handler code
    // force the control to redraw itself
    InvalidateControl();
	SetModifiedFlag();
}
