// wGui Calculator tutorial - bullseye.cpp #include "bullseye.h" using namespace wGui; CBullseye::CBullseye(const CRect& WindowRect, CWindow* pParent) : CPicture(WindowRect, pParent, "bullseye.bmp", true) { } bool CBullseye::OnMouseButtonDown(CPoint Point, unsigned int Button) // virtual { bool bResult = false; if (! CWindow::OnMouseButtonDown(Point, Button) && m_bVisible && GetClientRect().HitTest(Point) == CRect::RELPOS_INSIDE && Button == CMouseMessage::LEFT) { CPoint RelativeDistance = Point - m_WindowRect.Center(); int iDistance = sqrt(RelativeDistance.XPos() * RelativeDistance.XPos() + RelativeDistance.YPos() * RelativeDistance.YPos()); int iScore = 0; if (iDistance < 24) { iScore = 50; // 50 points for the center blue circle } else if (iDistance < 46) { iScore = 25; // 25 points for the white ring } // 0 points for the red area CMessageServer::Instance().QueueMessage(new TIntMessage(CMessage::USER, m_pParentWindow, this, iScore)); bResult = true; } return bResult; }