summaryrefslogtreecommitdiff
path: root/src/T2PoolView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2PoolView.cpp')
-rw-r--r--src/T2PoolView.cpp207
1 files changed, 207 insertions, 0 deletions
diff --git a/src/T2PoolView.cpp b/src/T2PoolView.cpp
index 13cfae6..f02934a 100644
--- a/src/T2PoolView.cpp
+++ b/src/T2PoolView.cpp
@@ -1,2 +1,209 @@
+#include "T2PeopleDemandList.h"
+#include "T2PeopleTimeZoneList.h"
+#include "T2PeopleType.h"
+#include "T2PeopleTypeArray.h"
+#include "T2Pool.h"
#include "T2PoolView.h"
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+#line 17
+IMPLEMENT_DYNCREATE(T2PoolView, CFrameWnd)
+
+T2PoolView::T2PoolView() {
+ mPool = NULL;
+}
+
+T2PoolView::~T2PoolView() {
+}
+
+BEGIN_MESSAGE_MAP(T2PoolView, CFrameWnd)
+ ON_WM_ERASEBKGND()
+ ON_WM_VSCROLL()
+ ON_WM_LBUTTONDOWN()
+END_MESSAGE_MAP()
+
+void T2PoolView::SetPool(T2Pool *inPool) {
+ mPool = inPool;
+ InvalidateRect(NULL);
+}
+
+BOOL T2PoolView::OnEraseBkgnd(CDC *pDC) {
+ Draw(pDC, NULL, NULL, NULL, NULL);
+ return true;
+}
+
+void T2PoolView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) {
+ int minPos, maxPos;
+ GetScrollRange(SB_VERT, &minPos, &maxPos);
+
+ int pos = GetScrollPos(SB_VERT);
+ switch (nSBCode) {
+ case SB_THUMBPOSITION:
+ case SB_THUMBTRACK:
+ pos = nPos;
+ break;
+ }
+
+ SetScrollPos(SB_VERT, pos);
+ InvalidateRect(NULL);
+}
+
+void T2PoolView::OnLButtonDown(UINT nFlags, CPoint point) {
+ T2PeopleTimeZoneList *peopleTimeZoneList = NULL;;
+ T2PeopleTypeArray *peopleTypeArray = NULL;
+ int weirdUnusedVariable = 0; // arbitrary name chosen to fit in
+ CDC *pDC = GetDC();
+
+ Draw(pDC, &point, &peopleTimeZoneList, &peopleTypeArray, &weirdUnusedVariable);
+
+ if (peopleTimeZoneList && !peopleTypeArray && !weirdUnusedVariable)
+ peopleTimeZoneList->_20 = !peopleTimeZoneList->_20;
+ if (peopleTimeZoneList && peopleTypeArray && !weirdUnusedVariable)
+ peopleTypeArray->m20 = !peopleTypeArray->m20;
+
+ ReleaseDC(pDC);
+ InvalidateRect(NULL);
+}
+
+void T2PoolView::Draw(CDC *pDC, CPoint *inPt, T2PeopleTimeZoneList **outTimeZoneList, T2PeopleTypeArray **outPeopleTypeArray, int *outUnknown) {
+#pragma var_order(peopleTimeZoneList, peopleDemandListIterator, peopleDemandList, str, font, save, totalPopulation, x, height, y, rect, pt, brush)
+ if (!mPool)
+ return;
+
+ CPoint pt;
+ if (inPt) {
+ pt = *inPt;
+ } else {
+ pt.x = 0;
+ pt.y = 0;
+ }
+
+ int save = pDC->SaveDC();
+
+ CRect rect;
+ GetClientRect(rect);
+
+ pDC->SetTextColor(RGB(0, 0, 0));
+ pDC->SetBkColor(RGB(255, 255, 255));
+
+ CBrush brush;
+ brush.CreateStockObject(WHITE_BRUSH);
+ if (!inPt)
+ pDC->FillRect(rect, &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;
+
+ int x = 4;
+ int y = -GetScrollPos(SB_VERT);
+
+ CString str;
+
+ T2PeopleDemandList *peopleDemandList = mPool->mDemandList;
+ LArrayIterator peopleDemandListIterator(*peopleDemandList);
+
+ T2PeopleTimeZoneList *peopleTimeZoneList;
+ int totalPopulation = 0;
+
+ while (peopleDemandListIterator.Next(&peopleTimeZoneList)) {
+#pragma var_order(demandStartY, peopleTypeArray, demandTotal, peopleTimeZoneListIterator)
+ int demandStartY = y;
+ int demandTotal = 0;
+
+ LArrayIterator peopleTimeZoneListIterator(*peopleTimeZoneList);
+ T2PeopleTypeArray *peopleTypeArray;
+
+ while (peopleTimeZoneListIterator.Next(&peopleTypeArray)) {
+#pragma var_order(peopleType, timeZoneStartY, peopleTypeArrayIterator, timeZoneTotal)
+ int timeZoneStartY = y;
+ int timeZoneTotal = 0;
+
+ LArrayIterator peopleTypeArrayIterator(*peopleTypeArray);
+ T2PeopleType peopleType;
+
+ while (peopleTypeArrayIterator.Next(&peopleType)) {
+ int peopleStartY = y;
+
+ timeZoneTotal++;
+ demandTotal++;
+ totalPopulation++;
+
+ if (peopleTypeArray->m20) {
+ str.Format(
+ " Sh=%-3d Dm=%-3d Tz=%-3d Lf=%-3d Et=%-3d",
+ peopleType.GetSilhouetteType(),
+ peopleType.GetDemandType(),
+ peopleType.GetTimeZoneType(),
+ peopleType.mLife,
+ peopleType.mEconoType
+ );
+
+ pDC->SetTextColor(RGB(0, 0, 0));
+ pDC->SetBkColor(RGB(255, 255, 255));
+
+ pDC->TextOut(x, y, str);
+ y += height;
+ }
+
+ if (peopleStartY <= pt.y && pt.y < y && outUnknown)
+ *outUnknown = 0;
+ }
+
+ if (peopleTimeZoneList->_20) {
+ str.Format(" TimeZone total : %d", timeZoneTotal);
+ if (peopleTypeArray->m20) {
+ pDC->SetTextColor(RGB(255, 255, 255));
+ pDC->SetBkColor(RGB(0, 0, 0));
+ } else {
+ pDC->SetTextColor(RGB(0, 0, 0));
+ pDC->SetBkColor(RGB(255, 255, 255));
+ }
+
+ pDC->TextOut(x, y, str);
+ y += height;
+ }
+
+ if (timeZoneStartY <= pt.y && pt.y < y && outPeopleTypeArray)
+ *outPeopleTypeArray = peopleTypeArray;
+ }
+
+ str.Format(" Demand total : %d", demandTotal);
+ if (peopleTimeZoneList->_20) {
+ pDC->SetTextColor(RGB(255, 255, 255));
+ pDC->SetBkColor(RGB(0, 0, 0));
+ } else {
+ pDC->SetTextColor(RGB(0, 0, 0));
+ pDC->SetBkColor(RGB(255, 255, 255));
+ }
+
+ pDC->TextOut(x, y, str);
+ y += height;
+
+ if (demandStartY <= pt.y && pt.y < y && outTimeZoneList)
+ *outTimeZoneList = peopleTimeZoneList;
+ }
+
+ pDC->SetTextColor(RGB(255, 255, 255));
+ pDC->SetBkColor(RGB(0, 0, 0));
+
+ str.Format("Total population : %d", totalPopulation);
+ pDC->TextOut(x, y, str);
+
+ y += height;
+
+ height = y + GetScrollPos(SB_VERT) - rect.Height();
+ if (height > 0)
+ SetScrollRange(SB_VERT, 0, height);
+ else
+ SetScrollRange(SB_VERT, 0, 0);
+
+ pDC->RestoreDC(save);
+}