summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2DlgItemTButton.cpp
blob: 04067a2b6a8a17f0185d838b6a553fc0083890d0 (plain)
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
#include "StdAfx.h"
#include "T2DlgItemTButton.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

T2DlgItemTButton::T2DlgItemTButton(T2TowerDoc* inDoc, T2ImageObj* inImageObj, CPalette* inPalette)
    : T2DlgItemButtonBase(inDoc, inImageObj, inPalette)
{
}

/*virtual*/ BOOL T2DlgItemTButton::OnT2DlgItemEraseBkgnd(CDC* pDC) {
#pragma var_order(rect, save, text)
    CString text;
    GetWindowText(text);

    if (text == "NULL")
        return true;

    CRect rect;
    GetClientRect(rect);

    DrawButtonBase(pDC, rect, GetPattern() == 100);

    int save = pDC->SaveDC();
    pDC->SelectPalette(mPalette, false);
    pDC->RealizePalette();

    pDC->SelectObject(mFont);
    pDC->SetBkMode(TRANSPARENT);

    if (!IsWindowEnabled())
        pDC->SetTextColor(PALETTERGB(179, 179, 179));
    else if (GetPattern() == 100)
        rect.OffsetRect(1, 1);
    else
        pDC->SetTextColor(RGB(0, 0, 0));

    pDC->DrawText(text, -1, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);

    pDC->RestoreDC(save);

    return true;
}