#include "T2DlgItemProfitsGage.h" #include "T2Tenant.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif T2DlgItemProfitsGage::T2DlgItemProfitsGage(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette) : T2DlgItemGageBase(inDoc, inImageObj, inPalette) , mTenant(NULL) { } void T2DlgItemProfitsGage::CalcCost() { mCost = mTenant->GetOutMoney(); } /*virtual*/ int T2DlgItemProfitsGage::GetMinValue() { int val = mCost * -1; if (mCost == 0) val = 0; return val; } /*virtual*/ int T2DlgItemProfitsGage::GetMaxValue() { int val; if (mCost == 0) val = 4; else val = (mCost * 230) / 70; return val; } /*virtual*/ int T2DlgItemProfitsGage::GetValue() { int val = GetMinValue(); if (mTenant) val = mTenant->CalcInMoney(); return val; } /*virtual*/ int T2DlgItemProfitsGage::GetBlueValue() { int val; if (mCost == 0) val = 2; else val = (mCost * 130) / 70; return val; } /*virtual*/ int T2DlgItemProfitsGage::GetYellowValue() { int val = 0; if (mCost == 0) val = 1; return val; } /*virtual*/ DWORD T2DlgItemProfitsGage::GetGageColor(int inValue) { return (inValue < GetYellowValue()) ? PALETTERGB(255, 0, 0) : (inValue < GetBlueValue()) ? PALETTERGB(255, 255, 0) : PALETTERGB(0, 0, 255); } void T2DlgItemProfitsGage::SetTenant(T2Tenant* inTenant) { mTenant = inTenant; CalcCost(); } /*virtual*/ void T2DlgItemProfitsGage::DrawInterior(CDC* pDC, const CRect& inRect) { T2DlgItemGageBase::DrawInterior(pDC, inRect); DrawValueByText(pDC, inRect); } /*virtual*/ BOOL T2DlgItemProfitsGage::IsDrawInterior() { return (mTenant != NULL); }