bool Board::isNear(int x, int y, Element el) const { if (Point(x, y).isBad(size)) return false; PointList nears = Point(x, y).getSurrounds(size); bool res = false; for (auto pt : nears) { res = res || isAt(pt.getX(), pt.getY(), el); } return res; }
PointList Board::findAll(Element el) const { PointList rslt; for (auto i = 0; i < size*size; ++i) { Point pt = xyl.getXY(i); if (isAt(pt.getX(), pt.getY(), el)) { rslt.push_back(pt); } } return rslt; }
int Board::countNear(int x, int y, Element el) const { PointList nearp = Point(x, y).getSurrounds(size); int count = 0; for (auto p : nearp) { if (isAt(p.getX(), p.getY(), el)) { ++count; } } return count; }
// ----------------------------------------------------------------- // Name : onButtonEvent // ----------------------------------------------------------------- guiObject * guiButton::onButtonEvent(ButtonAction * pEvent) { if ((pEvent->eButton != Button1 && (pEvent->eButton != Button2 || !m_bCatchButton2Events)) || !m_bEnabled || !m_bVisible) { return NULL; } switch (pEvent->eEvent) { case Event_Down: { m_bMouseDown = true; m_bMouseOver = true; m_bClickState = true; // TODO audio AudioManager::getInstance()->playSound(SOUND_CLICK); if (m_bMultiClicks) { m_fMultiClicksTimer = MULTICLICKS_TIMER_FIRST; memcpy(&m_MultiClicksEvent, pEvent, sizeof(ButtonAction)); bool bClose = doClick(pEvent); return bClose ? NULL : this; } return this; } case Event_Up: { m_bMouseDown = false; m_bClickState = false; bool bClose = false; if (!m_bMultiClicks && m_bMouseOver) { bClose = doClick(pEvent); } return bClose ? NULL : this; } case Event_Drag: { m_bClickState = m_bMouseOver = isAt(pEvent->xPos - pEvent->xOffset, pEvent->yPos - pEvent->yOffset); return this; } case Event_DoubleClick: { if (m_bCatchDoubleClicks) { bool bClose = false; if (m_bMouseOver && m_pOwner != NULL) { bClose = !m_pOwner->onButtonEvent(pEvent, this); } return bClose ? NULL : this; } break; } default: break; } return NULL; }
bool Board::isAt(int x, int y, std::list<Element> els) const { for (auto i : els) { if (isAt(x, y, i)) return true; } return false; }
bool operator !=(TR::TreeTop *tt) { return !isAt(tt); }
bool operator ==(TR::TreeTop *tt) { return isAt(tt); }
bool isAt(TreeTopIteratorImpl &other) { return isAt(other.currentTree()); }