#if !defined(__GENERALDRAW_INCLUDED__)
|
#define __GENERALDRAW_INCLUDED__
|
|
//////////////////////////////////////////////////////////////////////////
|
// Color
|
#define DLG_FONT_COLOR RGB(255,255,255)
|
#define DLG_BK_COLOR_1 RGB(0,128,128)
|
#define DLG_BK_COLOR_2 RGB(5,64,128)
|
#define DLG_BK_COLOR_3 RGB(10,20,30)
|
#define DLG_BK_COLOR_4 RGB(0,0,0)
|
|
//////////////////////////////////////////////////////////////////////////
|
// Font Control
|
const int MAX_FONT_COUNT = 9;
|
class CFontControl
|
{
|
public:
|
enum EN_FONT_SECTION{EN_MAINFONT=0,EN_SUBFONT,EN_SUBFONT_NORMAL,EN_ITEMFONT,EN_DATAFONT,EN_BUTTONFONT,EN_HANFONT,EN_LARGEFONT,EN_MIDDLEFONT};
|
|
CFontControl()
|
{
|
CreateFont(&m_Font[EN_MAINFONT],16,_T("Arial"));
|
CreateFont(&m_Font[EN_SUBFONT],18,_T("Arial"));
|
CreateFont(&m_Font[EN_SUBFONT_NORMAL],18,_T("Arial"),FW_NORMAL);
|
CreateFont(&m_Font[EN_ITEMFONT],14,_T("Arial"));
|
CreateFont(&m_Font[EN_DATAFONT],12,_T("Arial"));
|
CreateFont(&m_Font[EN_BUTTONFONT],24,_T("Arial"));
|
CreateFont(&m_Font[EN_HANFONT],12,_T("±¼¸²Ã¼"));
|
CreateFont(&m_Font[EN_LARGEFONT],48,_T("Arial"));
|
CreateFont(&m_Font[EN_MIDDLEFONT],35,_T("Arial"));
|
}
|
~CFontControl()
|
{
|
int i;
|
|
for(i=0;i<MAX_FONT_COUNT;i++)
|
{
|
if(m_Font[i].GetSafeHandle() != NULL)
|
m_Font[i].DeleteObject();
|
}
|
}
|
CFont *GetFont(EN_FONT_SECTION enFont) {return m_Font[enFont].GetSafeHandle() != NULL?&m_Font[enFont]:NULL;}
|
void SetFont(CWnd *pWnd,UINT nCID,EN_FONT_SECTION enFont)
|
{
|
if(enFont < 0 || enFont >= MAX_FONT_COUNT)
|
return;
|
|
pWnd->GetDlgItem(nCID)->SetFont(GetFont(enFont));
|
}
|
void CreateFont(CFont *pFont,int nFontSize,CString strFont,int nWidth=FW_BOLD)
|
{
|
if(pFont->GetSafeHandle() != NULL)
|
return;
|
|
pFont->CreateFont( nFontSize,// nHeight
|
nFontSize/2, // nWidth
|
0, // nEscapement
|
0, // nOrientation
|
nWidth , // nWeight
|
0, // bItalic
|
0, // bUnderline
|
0, // cStrikeOut
|
0, // nCharSet
|
OUT_DEFAULT_PRECIS, // nOutPrecision
|
0, // nClipPrecision
|
ANTIALIASED_QUALITY, // nQuality
|
// nPitchAndFamily
|
DEFAULT_PITCH | FF_DONTCARE,
|
strFont );
|
}
|
protected:
|
CFont m_Font[MAX_FONT_COUNT];
|
};
|
//////////////////////////////////////////////////////////////////////////
|
|
|
//////////////////////////////////////////////////////////////////////////
|
// Brush Control
|
const int MAX_BRUSH_COUNT = 6;
|
class CBrushControl
|
{
|
public:
|
enum EN_BRUSH_SECTION{EN_MAINBRUSH=0,EN_SUBBRUSH,EN_BACKBRUSH,EN_DATABRUSH,EN_MAINBKBRUSH,EN_WHITEBRUSH};
|
|
CBrushControl()
|
{
|
CreateBrush(&m_Brush[EN_MAINBRUSH],RGB(0,128,128));
|
CreateBrush(&m_Brush[EN_SUBBRUSH],RGB(0,0,0));
|
CreateBrush(&m_Brush[EN_BACKBRUSH],RGB(5,64,128));
|
CreateBrush(&m_Brush[EN_DATABRUSH],RGB(180,150,190));
|
CreateBrush(&m_Brush[EN_MAINBKBRUSH],RGB(10,20,30));
|
CreateBrush(&m_Brush[EN_WHITEBRUSH],RGB(255,255,255));
|
}
|
~CBrushControl()
|
{
|
int i;
|
|
for(i=0;i<MAX_BRUSH_COUNT;i++)
|
{
|
if(m_Brush[i].GetSafeHandle() != NULL)
|
m_Brush[i].DeleteObject();
|
}
|
}
|
CBrush *GetBrush(EN_BRUSH_SECTION enBrush) {return m_Brush[enBrush].GetSafeHandle() != NULL?&m_Brush[enBrush]:NULL;}
|
void CreateBrush(CBrush *pBrush,COLORREF crColor)
|
{
|
if(pBrush->GetSafeHandle() != NULL)
|
return;
|
|
pBrush->CreateSolidBrush(crColor);
|
}
|
protected:
|
CBrush m_Brush[MAX_BRUSH_COUNT];
|
};
|
//////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////
|
// Picture Box
|
|
enum EN_PICTURE_SECTION{EN_PICTURE_DEFAULT=0,EN_PICTURE_TITLEDEFAULT,EN_PICTURE_ITEMDEFAULT,EN_PICTURE_PROCESSDEFAULT,EN_PICTURE_PROCESSENABLE,EN_PICTURE_VALUEDEFAULT};
|
class CUIPictureControl
|
{
|
public:
|
BOOL m_bEnable;
|
CDC *m_pDC;
|
CString m_strData;
|
CString m_strFont;
|
int m_nFontsize;
|
int m_nInnerOffset;
|
COLORREF m_colBack;
|
COLORREF m_colInner;
|
COLORREF m_colText;
|
UINT m_nAlign;
|
CRect m_rect;
|
UINT m_nUID;
|
CWnd *m_pWnd;
|
CPoint m_FontOffset;
|
int m_nFontType;
|
|
public:
|
CUIPictureControl()
|
{
|
SetDefault();
|
}
|
~CUIPictureControl()
|
{
|
}
|
BOOL isVaildDC(){return (m_pDC!=NULL&&m_pDC->GetSafeHdc()!=NULL)?TRUE:FALSE;}
|
void SetDefault()
|
{
|
m_pWnd = NULL;
|
m_bEnable = TRUE;
|
m_pDC = NULL;
|
m_strData.Format(_T(""));
|
m_nInnerOffset = 2;
|
m_nFontsize = 12;
|
m_colBack = RGB(255,255,255);
|
m_colInner = RGB(0,0,0);
|
m_colText = RGB(255,255,255);
|
m_nAlign = DT_VCENTER|DT_CENTER;
|
m_rect = CRect(0,0,0,0);
|
m_nUID = 0;
|
m_FontOffset = CPoint(2,2);
|
m_nFontType = FW_BOLD;
|
m_strFont = _T("Arial");
|
}
|
void SetTitleDefault(CWnd *pWnd,UINT cID)
|
{
|
if(pWnd == NULL)
|
return;
|
|
m_pWnd = pWnd;
|
m_nUID = cID;
|
m_pDC = ((CWnd*)pWnd->GetDlgItem(cID))->GetDC();
|
((CWnd*)pWnd->GetDlgItem(cID))->GetClientRect(m_rect);
|
m_nFontsize = 24;
|
m_colInner = RGB(90,50,100);
|
m_FontOffset = CPoint(4,4);
|
}
|
void SetItemDefault(CWnd *pWnd,UINT cID)
|
{
|
if(pWnd == NULL)
|
return;
|
|
m_pWnd = pWnd;
|
m_nUID = cID;
|
m_pDC = ((CWnd*)pWnd->GetDlgItem(cID))->GetDC();
|
((CWnd*)pWnd->GetDlgItem(cID))->GetClientRect(m_rect);
|
m_nFontsize = 16;
|
m_colBack = RGB(180,180,180);
|
m_colInner = RGB(0,110,110);
|
m_colText = RGB(230,230,230);
|
m_FontOffset = CPoint(4,4);
|
}
|
void SetProcessDefault(CWnd *pWnd,UINT cID)
|
{
|
if(pWnd == NULL)
|
return;
|
|
m_pWnd = pWnd;
|
m_nUID = cID;
|
m_pDC = ((CWnd*)pWnd->GetDlgItem(cID))->GetDC();
|
((CWnd*)pWnd->GetDlgItem(cID))->GetClientRect(m_rect);
|
m_nFontsize = 16;
|
m_colBack = RGB(180,180,180);
|
m_colInner = RGB(128,128,128);
|
m_colText = RGB(200,200,200);
|
m_FontOffset = CPoint(4,8);
|
}
|
void SetValueDefault(CWnd *pWnd,UINT cID)
|
{
|
if(pWnd == NULL)
|
return;
|
|
m_pWnd = pWnd;
|
m_nUID = cID;
|
m_pDC = ((CWnd*)pWnd->GetDlgItem(cID))->GetDC();
|
((CWnd*)pWnd->GetDlgItem(cID))->GetClientRect(m_rect);
|
m_nFontsize = 20;
|
m_colBack = RGB(180,180,180);
|
m_colInner = RGB(110,110,255);
|
m_colText = RGB(230,230,230);
|
m_FontOffset = CPoint(4,8);
|
}
|
};
|
|
class CGeneralDraw
|
{
|
public:
|
CGeneralDraw(void);
|
~CGeneralDraw(void);
|
|
// Draw Picture Box
|
public:
|
void DrawPitureControl(CUIPictureControl &pPicture);
|
};
|
//////////////////////////////////////////////////////////////////////////
|
|
|
#endif
|