Beispiel #1
0
bool CListBox::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
	CPoint WindowPoint(ViewToWindow(Point));
	bool bResult = CWindow::OnMouseButtonDown(Point, Button);
 	if (!bResult && m_bVisible && (Button == CMouseMessage::LEFT) &&
		(m_WindowRect.SizeRect().HitTest(WindowPoint) == CRect::RELPOS_INSIDE))
	{
// judb for the moment disabled (this interferes with the keyboard focus handling, for example
// closing a frame with the Escape button)
// Should look at it when adding keyboard control for the entire gui.(most of the widgets don't respond
// to keyboard events yet)
//		if (CApplication::Instance()->GetKeyFocus() != this)
//		{
//			CApplication::Instance()->SetKeyFocus(this);
//		}

		if (!m_Items.empty() && m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE)
		{
			// Prep the new selection
      // judb m_iFocusedItem should be <= the number of items in the listbox (0-based, so m_Items.size() -1)
			m_iFocusedItem = std::min((WindowPoint.YPos() + m_ClientRect.Top()) / m_iItemHeight + m_pVScrollbar->GetValue(), stdex::safe_static_cast<unsigned int>(m_Items.size()) - 1);
		}
		bResult = true;
	}

	return bResult;
}
Beispiel #2
0
bool CListBox::OnMouseButtonUp(CPoint Point, unsigned int Button)
{
	bool bResult = CWindow::OnMouseButtonUp(Point, Button);

	CPoint WindowPoint(ViewToWindow(Point));
	if (!bResult && m_bVisible && (Button == CMouseMessage::LEFT) && (m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE))
	{
        // judb m_iFocusedItem should be <= the number of items in the listbox (0-based, so m_Items.size() - 1)
		if (m_iFocusedItem == std::min(((WindowPoint.YPos() - m_ClientRect.Top()) / m_iItemHeight + m_pVScrollbar->GetValue()), stdex::safe_static_cast<unsigned int>(m_Items.size()) - 1))
		{
			if (m_bSingleSelection)
			{
				SetAllSelections(false);
			}
			SetSelection(m_iFocusedItem, !IsSelected(m_iFocusedItem));
			CWindow* pDestination = m_pParentWindow;
			if (m_pDropDown)
			{
				pDestination = m_pDropDown;
			}
			CMessageServer::Instance().QueueMessage(new TIntMessage(CMessage::CTRL_VALUECHANGE, pDestination, this, m_iFocusedItem));
			Draw();
		}
		bResult = true;
	}

	return bResult;
}
bool CNavigationBar::OnMouseButtonDown(CPoint Point, unsigned int Button)
{
	CPoint WindowPoint(ViewToClient(Point));
	bool bResult = CWindow::OnMouseButtonDown(Point, Button);
 	if (!bResult && m_bVisible && (Button == CMouseMessage::LEFT))
	{
		if (!m_Items.empty() && m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE) {
			// Prep the new selection
      // judb m_iFocusedItem should be <= the number of items in the bar (0-based, so m_Items.size() - 1)
			m_iFocusedItem = stdex::MinInt((WindowPoint.XPos() / m_iItemWidth), m_Items.size() - 1);
			SelectItem(m_iFocusedItem);
      bResult = true;
		}
	}
	return bResult;
}
Beispiel #4
0
bool CListBox::OnMouseButtonUp(CPoint Point, unsigned int Button)
{
	bool bResult = CWindow::OnMouseButtonUp(Point, Button);

	CPoint WindowPoint(ViewToWindow(Point));
	if (!bResult && m_bVisible && (Button == CMouseMessage::LEFT) && (m_ClientRect.HitTest(WindowPoint) == CRect::RELPOS_INSIDE))
	{
        // judb m_iFocusedItem should be <= the number of items in the listbox (0-based, so m_Items.size() - 1)
		if (m_iFocusedItem == std::min(((WindowPoint.YPos() - m_ClientRect.Top()) / m_iItemHeight + m_pVScrollbar->GetValue()), stdex::safe_static_cast<unsigned int>(m_Items.size()) - 1))
		{
			SetSelection(m_iFocusedItem, !IsSelected(m_iFocusedItem));
		}
		bResult = true;
	}

	return bResult;
}