基本思路
#pragma once
#include <map>
struct IPainter
{
void Paint() {}
};
class Element
{
void SetPainterState(int dwState, IPainter* pPainter)
{
m_mapStatePainter[dwState]=pPainter;
if(dwState==m_dwState)
{
GoToState(dwState);
}
}
IPainter* GetPainterState(int dwState)
{
return m_mapStatePainter[m_dwState];
}
int GetState()
{
return m_dwState;
}
void GoToState(int dwState)
{
m_dwState=dwState;
//InvalidateRect();
}
void Paint()
{
m_mapStatePainter[m_dwState]->Paint();
}
private:
int m_dwState;
std::map<int,IPainter*> m_mapStatePainter;
};