void MapGridCtrl::OnLeftUp(wxMouseEvent& event)
{
	SetCursor(wxCursor(wxCURSOR_ARROW));
	m_in_mouse_drag = false;

	if (wxPoint2DInt(event.GetPosition() - m_first_mouse_pos).GetVectorLength() <= 3) {
		SelectMap(m_mouseover_map);
	}
}
void MapGridCtrl::OnMouseMove(wxMouseEvent& event)
{
	SetCursor(wxCursor(wxCURSOR_HAND));
	if (m_in_mouse_drag) {
		// Fix for for not receiving LeftUp event when left button
		// is released outside the control (happens on Windows.)
		if (!event.LeftIsDown()) {
			OnLeftUp(event);
			return;
		}

		m_pos -= (event.GetPosition() - m_last_mouse_pos);
		m_last_mouse_pos = event.GetPosition();

		CheckInBounds();
		Refresh();
	} else {
		const wxPoint pos_unscaled = event.GetPosition() + m_pos;
		const wxPoint pos = wxPoint2DInt(pos_unscaled) / (MINIMAP_SIZE + MINIMAP_MARGIN);
		const int idx = pos.y * m_size.x + pos.x;
		MapData* old_mouseover_map = m_mouseover_map;

		// use pos_unscaled for tests against 0 because negative values lower
		// than MINIMAP_SIZE get rounded up to 0 when diviving by MINIMAP_SIZE..
		if (pos_unscaled.x >= 0 && pos.x < m_size.x && pos_unscaled.y >= 0 && pos.y <= m_size.y && idx < (int)m_grid.size()) {
			m_mouseover_map = m_grid[idx];
		} else {
			m_mouseover_map = NULL;
		}

		if (m_mouseover_map != old_mouseover_map) {
			if (m_selection_follows_mouse && m_mouseover_map != NULL) {
				SelectMap(m_mouseover_map);
			}
		}
	}
}
Beispiel #3
0
void wxBlockIntSelectionIterator::Reset()
{
    m_block_index = -1;
    m_pt = wxPoint2DInt(0, 0);
}