1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#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