#ifndef barmeter_h_included
#define barmeter_h_included

// $Id$

/////////////////////////////////////////////////////////////////////////////
// Enum Types


/////////////////////////////////////////////////////////////////////////////
// CBarMeter command target

class CBarMeter:public CWnd
{
   DECLARE_DYNCREATE(CBarMeter)
   CBarMeter();
   virtual ~CBarMeter();

   COLORREF nearestColor(COLORREF c);

// Operations
public:
   enum MeterMemberEnum {
      meter_title,
      meter_needle,
      meter_grid,
      meter_gridalert,
      meter_value,
      meter_range,
      meter_unit,
      meter_bground,
   };

   void    ShowMeter   (CDC * pDC, CRect rectBorder);
   void    UpdateNeedle(CDC * pDC, double dPos);


   void    SetColor(enum MeterMemberEnum meter_member, COLORREF Color);
   void    SetState(enum MeterMemberEnum meter_member, bool State);
   void    SetRange(double dMin, double dMax);
   void    SetAlert(double dAlert);
   void    SetFontScale(int nFontScale);
   void    SetRangeDecimals(int nRangeDecimals);
   void    SetValueDecimals(int nValueDecimals);
   void    SetTitle(CString strTitle);
   void    SetUnit(CString strUnit);


   void    GetColor(enum MeterMemberEnum meter_member, COLORREF * pColor);
   void    GetState(enum MeterMemberEnum meter_member, bool * pState);
   double  GetMinRange()      { return m_dMinScale;      }
   double  GetMaxRange()      { return m_dMaxScale;      }
   double  GetAlert()         { return m_dAlertScale;    }
   int     GetFontScale()     { return m_nFontScale;     }
   int     GetRangeDecimals() { return m_nRangeDecimals; }
   int     GetValueDecimals() { return m_nValueDecimals; }
   CString GetTitle()         { return m_strTitle;       }
   CString GetUnit()          { return m_strUnit;        }


   // Overrides
   // ClassWizard generated virtual function overrides
   //{{AFX_VIRTUAL(CBarMeter)
   //}}AFX_VIRTUAL

   // Implementation
protected:
   void           DrawGrid();
   void           DrawNeedle();
   void           ShowMeterImage(CDC * pDC);
   void           ActuateColors();

   bool           m_swTitle;
   bool           m_swGrid;
   bool           m_swValue;
   bool           m_swRange;
   bool           m_swUnit;

   COLORREF       m_colorTitle;
   COLORREF       m_colorNeedle;
   COLORREF       m_colorGrid;
   COLORREF       m_colorGridAlert;
   COLORREF       m_colorValue;
   COLORREF       m_colorRange;
   COLORREF       m_colorBGround;

   bool           m_boolUseBitmaps;
   bool           m_boolForceRedraw;

   int            m_nFontScale;
   int            m_nRangeDecimals;
   int            m_nValueDecimals;
   int            m_nRectWidth;
   int            m_nRectHeight;
   int            m_nCXPix;
   int            m_nCYPix;
   int            m_nRadiusPix;
   int            m_nLeftLimitXPix;
   int            m_nLeftLimitYPix;
   int            m_nRightLimitXPix;
   int            m_nRightLimitYPix;
   int            m_nHalfBaseWidth;
   int            m_nTextBaseSpacing;
   int            m_nFontHeight;


   double         m_dPI;
   double         m_dLimitAngleDeg;
   double         m_dLimitAngleRad;
   double         m_dRadiansPerValue;
   double         m_dNeedlePos;
   double         m_dMinScale;
   double         m_dMaxScale;
   double         m_dAlertScale;


   CString        m_strTitle;
   CString        m_strUnit;

   CDC            m_dcGrid;
   CBitmap        m_bitmapGrid;
   CBitmap       *m_pbitmapOldGrid;

   CDC            m_dcNeedle;
   CBitmap        m_bitmapNeedle;
   CBitmap       *m_pbitmapOldNeedle;

   CRect          m_rectDraw;
   CRect          m_rectGfx;
   CRect          m_rectOwner;
   CRect          m_rectMinValue;
   CRect          m_rectMaxValue;
   CRect          m_rectValue;

   CFont          m_fontValue;

   CPen           m_PenG_Grid;
   CBrush         m_BrushG_Grid;
   CPen           m_PenG_GridAlert;
   CBrush         m_BrushG_GridAlert;
   CPen           m_PenG_BGround;
   CBrush         m_BrushG_BGround;

   CPen           m_PenN_Needle;
   CBrush         m_BrushN_Needle;
   CPen           m_PenN_BGround;
   CBrush         m_BrushN_BGround;

   // Generated message map functions
   //{{AFX_MSG(CBarMeter)
   // NOTE - the ClassWizard will add and remove member functions here.
   //}}AFX_MSG

   DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////

#endif  /* barmeter_h_included */

