summaryrefslogtreecommitdiff
path: root/src/DbgPeopleView.cpp
blob: 91d17b65c798cb4703a05ed53faebfbac8d41db8 (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
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
#include "StdAfx.h"
#include "DbgPeopleView.h"
#include "T2DLL/T2People.h"
#include "T2DLL/T2PeopleArray.h"
#include "T2DLL/T2PeopleArrayList.h"

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

#line 16
IMPLEMENT_DYNCREATE(DbgPeopleView, CFrameWnd)

DbgPeopleView::DbgPeopleView() {
    mPeopleArrayList = NULL;
}

/*virtual*/ DbgPeopleView::~DbgPeopleView() {
}

BEGIN_MESSAGE_MAP(DbgPeopleView, CFrameWnd)
    //{{AFX_MSG_MAP(DbgPeopleView)
    ON_WM_ERASEBKGND()
    ON_WM_CREATE()
    ON_WM_TIMER()
    ON_WM_DESTROY()
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

void DbgPeopleView::SetPeople(T2PeopleArrayList *inList) {
    mPeopleArrayList = inList;
}

BOOL DbgPeopleView::OnEraseBkgnd(CDC *pDC) {
#pragma var_order(str, font, save, height, iter, y, peopleArray, theFrameRect, brush)
    if (!mPeopleArrayList)
        return CFrameWnd::OnEraseBkgnd(pDC);

    int save = pDC->SaveDC();

    CRect theFrameRect;
    GetClientRect(theFrameRect);

    pDC->SetTextColor(RGB(0, 0, 0));
    pDC->SetBkColor(RGB(255, 255, 255));

    CBrush brush;
    brush.CreateStockObject(WHITE_BRUSH);
    pDC->FillRect(theFrameRect, &brush);

    CFont font;
    font.CreateFont(-12, 0, 0, 0, FW_NORMAL, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, DRAFT_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x83\x53\x83\x56\x83\x62\x83\x4E");
    pDC->SelectObject(&font);

    int height = pDC->GetTextExtent("A").cy + 1;
    pDC->SetTextAlign(TA_UPDATECP);
    int y = 2;

    CString str;
    LArrayIterator iter(*mPeopleArrayList);
    T2PeopleArray *peopleArray;

    while (iter.Next(&peopleArray)) {
        for (int i = 0; i < T2PeopleArray::kGroupSize; i++) {
            T2People *people = &peopleArray->mPeople[i];

            if (people->IsUsed() && !people->mPrev) {
                pDC->MoveTo(2, y);

                str.Format("(%04d) %04d", people->mCurrEquipID, people->mMatterID);
                pDC->TextOut(0, 0, str);

                T2People *prevPeople = people;
                people = (T2People *) people->mNext;
                int j = 0;

                while (people && j < 100) {
                    if (prevPeople == people->mPrev)
                        pDC->SetTextColor(RGB(0, 0, 0));
                    else
                        pDC->SetTextColor(RGB(255, 0, 0));
                    pDC->TextOut(0, 0, " \x81\xA8 ");

                    pDC->SetTextColor(RGB(0, 0, 0));

                    str.Format("%04d:%02d", people->mMatterID, people->GetStatus());
                    pDC->TextOut(0, 0, str);

                    prevPeople = people;
                    people = (T2People *) people->mNext;
                    j++;
                }

                y += height;
            }
        }
    }

    pDC->RestoreDC(save);
    return true;
}

int DbgPeopleView::OnCreate(LPCREATESTRUCT lpCreateStruct) {
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    SetTimer(1, 100, NULL);
    return 0;
}

void DbgPeopleView::OnTimer(UINT nIDEvent) {
    InvalidateRect(NULL);
}

void DbgPeopleView::OnDestroy() {
    CFrameWnd::OnDestroy();
    KillTimer(1);
}