summaryrefslogtreecommitdiff
path: root/src/T2MsgWindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2MsgWindow.cpp')
-rw-r--r--src/T2MsgWindow.cpp157
1 files changed, 157 insertions, 0 deletions
diff --git a/src/T2MsgWindow.cpp b/src/T2MsgWindow.cpp
index 1394f19..d63d054 100644
--- a/src/T2MsgWindow.cpp
+++ b/src/T2MsgWindow.cpp
@@ -1,2 +1,159 @@
+#include "T2DlgItemAnimation.h"
+#include "T2ImageObj.h"
#include "T2MsgWindow.h"
+#include "T2MWControl.h"
+#include "T2TowerDoc.h"
+#include "T2WorldDef.h"
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+#line 19
+IMPLEMENT_DYNCREATE(T2MsgWindow, CFrameWnd)
+
+T2MsgWindow::T2MsgWindow() {
+#line 23
+ mClockControl = new T2MWControl;
+ mCalendarControl = new T2MWControl;
+ mFundsControl = new T2MWControl;
+
+#line 30
+ mPopulationControl = new T2MWControl;
+ mMessageControl = new T2MWControl;
+
+ mDocument = NULL;
+ mWorldDef = NULL;
+ mIsSetUp = false;
+}
+
+/*virtual*/ T2MsgWindow::~T2MsgWindow() {
+ delete mClockControl;
+ delete mCalendarControl;
+ delete mFundsControl;
+ delete mPopulationControl;
+ delete mMessageControl;
+}
+
+BEGIN_MESSAGE_MAP(T2MsgWindow, CFrameWnd)
+ ON_WM_QUERYNEWPALETTE()
+ ON_WM_ERASEBKGND()
+ ON_WM_CREATE()
+ ON_WM_CLOSE()
+END_MESSAGE_MAP()
+
+void T2MsgWindow::SetDocument(T2TowerDoc *inDoc) {
+ mDocument = inDoc;
+ mWorldDef = inDoc->mWorldDef;
+
+ mWndClass = AfxRegisterWndClass(CS_NOCLOSE, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH));
+
+ RECT rect;
+
+ mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Clock", 0), rect);
+ mClockControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1000);
+
+ mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Calendar", 0), rect);
+ mCalendarControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1001);
+
+ mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Funds", 0), rect);
+ mFundsControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1002);
+
+ mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Population", 0), rect);
+ mPopulationControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1003);
+
+ mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Message", 0), rect);
+ mMessageControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1004);
+
+ mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Grade", 0), rect);
+#line 80
+ mGradeControl = new T2DlgItemAnimation(mDocument, NULL, mWorldDef->GetPalette());
+
+ mGradeControl->Create("", WS_CLIPCHILDREN | WS_VISIBLE | WS_CHILD, rect, this, 1005);
+
+ mClockControl->Setup(inDoc);
+ mCalendarControl->Setup(inDoc);
+ mFundsControl->Setup(inDoc);
+ mPopulationControl->Setup(inDoc);
+ mMessageControl->Setup(inDoc);
+
+ mToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);
+ mToolTip.AddTool(mClockControl);
+ mToolTip.AddTool(mCalendarControl);
+ mToolTip.AddTool(mFundsControl);
+ mToolTip.AddTool(mPopulationControl);
+ mToolTip.AddTool(mMessageControl);
+ mToolTip.Activate(true);
+
+ mIsSetUp = true;
+ InvalidateRect(NULL);
+}
+
+int T2MsgWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) {
+ if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
+ return -1;
+
+ RECT windowRect, clientRect;
+ GetWindowRect(&windowRect);
+ GetClientRect(&clientRect);
+
+ SetWindowPos(NULL,
+ 0,
+ 0,
+ (windowRect.right - windowRect.left) - clientRect.right + 512,
+ (windowRect.bottom - windowRect.top) - clientRect.bottom + 44,
+ SWP_NOMOVE | SWP_NOZORDER
+ );
+ return 0;
+}
+
+BOOL T2MsgWindow::OnQueryNewPalette() {
+ return CFrameWnd::OnQueryNewPalette();
+}
+
+BOOL T2MsgWindow::OnEraseBkgnd(CDC *pDC) {
+ if (!mDocument)
+ return CFrameWnd::OnEraseBkgnd(pDC);
+
+ pDC->SaveDC();
+ pDC->SelectPalette(mWorldDef->GetPalette(), false);
+
+ int objInd = mWorldDef->mImageObj->FindObject("MsgWnd");
+
+ RECT rect;
+ SetRect(&rect, 0, 0, 513, 45);
+ mWorldDef->mImageObj->DrawObject(pDC, objInd, rect);
+
+ pDC->RealizePalette();
+ pDC->RestoreDC(-1);
+
+ return true;
+}
+
+/*virtual*/ BOOL T2MsgWindow::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT *pResult) {
+ LPNMTTDISPINFO msg = (LPNMTTDISPINFO) lParam;
+ int id = ::GetDlgCtrlID((HWND) msg->hdr.idFrom);
+
+ if (msg->hdr.code == TTN_GETDISPINFO && (id >= 1000) && (id <= 1003)) {
+ mWorldDef->GetToolTipText(mDocument, (T2MWControl *) GetDlgItem(id), msg);
+ return true;
+ }
+
+ return CWnd::OnNotify(wParam, lParam, pResult);
+}
+
+void T2MsgWindow::OnClose() {
+ if (!mDocument)
+ return;
+
+ mDocument->towerDoc_vf198(kMessageWindow);
+}
+
+/*virtual*/ BOOL T2MsgWindow::PreTranslateMessage(MSG *pMsg) {
+ if (mIsSetUp)
+ mToolTip.RelayEvent(pMsg);
+
+ return CFrameWnd::PreTranslateMessage(pMsg);
+}