diff options
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2BalloonWnd.cpp | 284 |
1 files changed, 260 insertions, 24 deletions
diff --git a/src/T2DLL/T2BalloonWnd.cpp b/src/T2DLL/T2BalloonWnd.cpp index a17dc4f..df8285f 100644 --- a/src/T2DLL/T2BalloonWnd.cpp +++ b/src/T2DLL/T2BalloonWnd.cpp @@ -1,52 +1,288 @@ +#include "GlobalFunc.h" #include "T2BalloonWnd.h" +#include "T2TowerDoc.h" +#include "T2TowerMainView.h" -/*static*/ CObject* __stdcall T2BalloonWnd::CreateObject() { -} - -/*static*/ CRuntimeClass* __stdcall T2BalloonWnd::_GetBaseClass() { -} - -/*virtual*/ CRuntimeClass* T2BalloonWnd::GetRuntimeClass() const { +CObject* PASCAL T2BalloonWnd::CreateObject() { +#line 16 + return DEBUG_NEW T2BalloonWnd; } +IMPLEMENT_DYNAMIC(T2BalloonWnd, CFrameWnd); T2BalloonWnd::T2BalloonWnd() { + mVisible = false; } /*virtual*/ T2BalloonWnd::~T2BalloonWnd() { } -/*static*/ const AFX_MSGMAP* __stdcall T2BalloonWnd::_GetBaseMessageMap() { -} +BEGIN_MESSAGE_MAP(T2BalloonWnd, CFrameWnd) + ON_WM_ERASEBKGND() + ON_WM_LBUTTONDOWN() + ON_WM_RBUTTONDOWN() + ON_WM_MOUSEMOVE() + ON_WM_TIMER() + ON_WM_DESTROY() +END_MESSAGE_MAP() -/*virtual*/ const AFX_MSGMAP* T2BalloonWnd::GetMessageMap() const { -} +#pragma var_order(rect4, rect5, rect1, save, rect7, rgn4, rect2, rect3, pDC) +void T2BalloonWnd::Show(int inX, int inY, const CString& inText, BOOL inIsPause) { + mIsPause = inIsPause; -void T2BalloonWnd::Show(int, int, const CString&, int) { -} + mFont.CreatePointFont(100, "\x82\x6C\x82\x72 \x82\x6F\x83\x53\x83\x56\x83\x62\x83\x4E"); -int T2BalloonWnd::OnEraseBkgnd(CDC*) { -} + mWndClass = AfxRegisterWndClass(CS_NOCLOSE, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); -void T2BalloonWnd::OnLButtonDown(unsigned int, CPoint) { -} + CRect rect1(0, 0, 50, 50); + Create(mWndClass, inText, WS_POPUP, rect1, AfxGetMainWnd(), NULL, WS_EX_TOPMOST); + + CRect rect2; + GetClientRect(rect2); + ClientToScreen(rect2); + + CRect rect3; + rect3.top = rect2.top - rect1.top; + rect3.left = rect2.left - rect1.left; + rect3.bottom = rect1.bottom - rect2.bottom; + rect3.right = rect1.right - rect2.right; + + CDC *pDC = GetDC(); + int save = pDC->SaveDC(); + pDC->SelectObject(mFont); + + mRect1.SetRectEmpty(); + // 123456789012345 + pDC->DrawText("\x82\x50\x82\x51\x82\x52\x82\x53\x82\x54\x82\x55\x82\x56\x82\x57\x82\x58\x82\x4F\x82\x50\x82\x51\x82\x52\x82\x53\x82\x54", &mRect1, DT_SINGLELINE | DT_CALCRECT); + pDC->DrawText(inText, &mRect1, DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX); + + mRect1.NormalizeRect(); + mRect1.OffsetRect(-mRect1.left, -mRect1.top); + + mRect2.SetRect(10, 10, 10, 10); + mRect1.OffsetRect(mRect2.left, mRect2.top); + + CRect rect4; + GetDesktopWindow()->GetClientRect(rect4); + + CRect rect5; + rect5 = mRect1; + rect5 += mRect2; + rect5.InflateRect(0, 0, 0, 16); + rect5.NormalizeRect(); + rect5.OffsetRect(-rect5.left, -rect5.top); + rect5.OffsetRect(inX, inY - rect5.Height()); + mDirection = 1; + + if (rect1.SubtractRect(rect5, rect4)) { + rect5 = mRect1; + rect5 += mRect2; + rect5.InflateRect(0, 0, 0, 16); + rect5.NormalizeRect(); + rect5.OffsetRect(-rect5.left, -rect5.top); + rect5.OffsetRect(inX - rect5.Width(), inY - rect5.Height()); + mDirection = 0; + + if (rect1.SubtractRect(rect5, rect4)) { + rect5 = mRect1; + rect5 += mRect2; + rect5.InflateRect(0, 0, 0, 16); + rect5.NormalizeRect(); + rect5.OffsetRect(-rect5.left, -rect5.top); + rect5.OffsetRect(inX, inY); + mDirection = 3; + + if (rect1.SubtractRect(rect5, rect4)) { + rect5 = mRect1; + rect5 += mRect2; + rect5.InflateRect(0, 0, 0, 16); + rect5.NormalizeRect(); + rect5.OffsetRect(-rect5.left, -rect5.top); + rect5.OffsetRect(inX - rect5.Width(), inY); + mDirection = 2; + } + } + } + + rect5 += rect3; + SetWindowPos(NULL, rect5.left, rect5.top, rect5.Width(), rect5.Height(), SWP_NOZORDER | SWP_NOACTIVATE); + rect5 -= rect3; + + rect5.OffsetRect(-rect5.left, -rect5.top); + + CRect rect7(1, 1, 1, 1); + rect5 -= rect7; + + if (mDirection == 1) { + mRgn.CreateRectRgn(0, 0, 1, 1); -void T2BalloonWnd::OnRButtonDown(unsigned int, CPoint) { + CRgn baseRegion; + baseRegion.CreateRoundRectRgn(rect5.left, rect5.top, rect5.right, rect5.bottom - 16, 20, 20); + + CRgn arrowRegion; + POINT arrowPoints[3]; + arrowPoints[0].x = rect5.left + 10; + arrowPoints[0].y = rect5.bottom - 18; + arrowPoints[1].x = rect5.left; + arrowPoints[1].y = rect5.bottom; + arrowPoints[2].x = rect5.left + 21; + arrowPoints[2].y = rect5.bottom - 18; + arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE); + mRgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR); + } else if (mDirection == 0) { + mRgn.CreateRectRgn(0, 0, 1, 1); + + CRgn baseRegion; + baseRegion.CreateRoundRectRgn(rect5.left, rect5.top, rect5.right, rect5.bottom - 16, 20, 20); + + CRgn arrowRegion; + POINT arrowPoints[3]; + arrowPoints[0].x = rect5.right - 10; + arrowPoints[0].y = rect5.bottom - 18; + arrowPoints[1].x = rect5.right; + arrowPoints[1].y = rect5.bottom; + arrowPoints[2].x = rect5.right - 21; + arrowPoints[2].y = rect5.bottom - 18; + arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE); + mRgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR); + } else if (mDirection == 3) { + mRect1.OffsetRect(0, 16); + mRgn.CreateRectRgn(0, 0, 1, 1); + + CRgn baseRegion; + baseRegion.CreateRoundRectRgn(rect5.left, rect5.top + 16, rect5.right, rect5.bottom, 20, 20); + + CRgn arrowRegion; + POINT arrowPoints[3]; + arrowPoints[0].x = rect5.left + 10; + arrowPoints[0].y = rect5.top + 18; + arrowPoints[1].x = rect5.left; + arrowPoints[1].y = rect5.top; + arrowPoints[2].x = rect5.left + 21; + arrowPoints[2].y = rect5.top + 18; + arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE); + mRgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR); + } else if (mDirection == 2) { + mRect1.OffsetRect(0, 16); + mRgn.CreateRectRgn(0, 0, 1, 1); + + CRgn baseRegion; + baseRegion.CreateRoundRectRgn(rect5.left, rect5.top + 16, rect5.right, rect5.bottom, 20, 20); + + CRgn arrowRegion; + POINT arrowPoints[3]; + arrowPoints[0].x = rect5.right - 10; + arrowPoints[0].y = rect5.top + 18; + arrowPoints[1].x = rect5.right; + arrowPoints[1].y = rect5.top; + arrowPoints[2].x = rect5.right - 21; + arrowPoints[2].y = rect5.top + 18; + arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE); + mRgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR); + } else { + mRgn.CreateRoundRectRgn(rect5.left, rect5.top, rect5.right, rect5.bottom, 20, 20); + } + + CRgn rgn4; + rgn4.CreateRectRgn(0, 0, 1, 1); + rgn4.CopyRgn(&mRgn); + rgn4.OffsetRgn(rect3.left, rect3.top); + ::SetWindowRgn(m_hWnd, rgn4, true); + + rgn4.Detach(); + pDC->RestoreDC(save); + ReleaseDC(pDC); + + ShowWindow(SW_SHOWNA); + SetCapture(); + + mVisible = true; + GetCursorPos(&mStartCursorPos); + + if (mIsPause) + GetCurrentT2TowerDoc()->towerDoc_vf290(true); + + SetTimer(1, 1500, NULL); } -void T2BalloonWnd::OnMouseMove(unsigned int, CPoint) { +#pragma var_order(brush, text, save, clientRect) +afx_msg BOOL T2BalloonWnd::OnEraseBkgnd(CDC* pDC) { + int save = pDC->SaveDC(); + + CRect clientRect; + GetClientRect(clientRect); + pDC->FillSolidRect(clientRect, RGB(255, 255, 255)); + + CBrush brush; + brush.CreateStockObject(BLACK_BRUSH); + pDC->FrameRgn(&mRgn, &brush, 1, 1); + + pDC->SetBkMode(TRANSPARENT); + pDC->SetTextColor(RGB(0, 0, 0)); + pDC->SelectObject(mFont); + + CString text; + GetWindowText(text); + pDC->DrawText(text, &mRect1, DT_WORDBREAK | DT_NOPREFIX); + + pDC->RestoreDC(save); + + return true; } -void T2BalloonWnd::OnTimer(unsigned int) { +afx_msg void T2BalloonWnd::OnLButtonDown(UINT nFlags, CPoint point) { + ClientToScreen(&point); + ShowWindow(SW_HIDE); + ReleaseCapture(); + mVisible = false; + DestroyWindow(); + + CWnd *belowWindow = WindowFromPoint(point); + if (belowWindow->m_hWnd == ((CFrameWnd *) AfxGetMainWnd())->GetActiveView()->m_hWnd) { + belowWindow->ScreenToClient(&point); + belowWindow->SendMessage(WM_LBUTTONDOWN, nFlags, MAKELONG(point.x, point.y)); + } } -void T2BalloonWnd::OnDestroy() { +afx_msg void T2BalloonWnd::OnRButtonDown(UINT nFlags, CPoint point) { + ClientToScreen(&point); + ShowWindow(SW_HIDE); + ReleaseCapture(); + mVisible = false; + DestroyWindow(); + + CWnd *belowWindow = WindowFromPoint(point); + if (belowWindow->m_hWnd == ((CFrameWnd *) AfxGetMainWnd())->GetActiveView()->m_hWnd) { + belowWindow->ScreenToClient(&point); + belowWindow->SendMessage(WM_RBUTTONDOWN, nFlags, MAKELONG(point.x, point.y)); + } } -/*static*/ const CRuntimeClass T2BalloonWnd::classT2BalloonWnd { +afx_msg void T2BalloonWnd::OnMouseMove(UINT nFlags, CPoint point) { + POINT cursor; + GetCursorPos(&cursor); + + if (abs(mStartCursorPos.x - cursor.x) > 3 || abs(mStartCursorPos.y - cursor.y) > 3) { + ShowWindow(SW_HIDE); + ReleaseCapture(); + mVisible = false; + DestroyWindow(); + } } -/*static*/ const AFX_MSGMAP T2BalloonWnd::messageMap { +afx_msg void T2BalloonWnd::OnTimer(UINT nIDEvent) { + if (nIDEvent == 1) { + ShowWindow(SW_HIDE); + ReleaseCapture(); + mVisible = false; + DestroyWindow(); + } } -/*static*/ const AFX_MSGMAP_ENTRY* const T2BalloonWnd::_messageEntries { +afx_msg void T2BalloonWnd::OnDestroy() { + CFrameWnd::OnDestroy(); + + if (mIsPause) + GetCurrentT2TowerDoc()->towerDoc_vf294(); + + KillTimer(1); } |