Exemple #1
0
bool CDropDownUI::SelectItem(int iIndex)
{
	if( iIndex == m_iCurSel ) return true;
	if( m_iCurSel >= 0 ) {
		CControlUI* pControl = static_cast<CControlUI*>(m_items[m_iCurSel]);
		IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
		if( pListItem != NULL ) pListItem->Select(false);
		m_iCurSel = -1;
	}
	if( m_items.GetSize() == 0 ) return false;
	if( iIndex < 0 ) iIndex = 0;
	if( iIndex >= m_items.GetSize() ) iIndex = m_items.GetSize() - 1;
	CControlUI* pControl = static_cast<CControlUI*>(m_items[iIndex]);
	if( !pControl->IsVisible() ) return false;
	if( !pControl->IsEnabled() ) return false;
	IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
	if( pListItem == NULL ) return false;
	m_iCurSel = iIndex;
	pControl->SetFocus();
	pListItem->Select(true);
	if( m_pManager != NULL ) m_pManager->SendNotify(pControl, _T("itemclick"));
	if( m_pManager != NULL ) m_pManager->SendNotify(this, _T("itemselect"));
	Invalidate();
	return true;
}
Exemple #2
0
bool CListUI::SelectItem(int iIndex)
{
   if( iIndex == m_iCurSel ) return true;
   // We should first unselect the currently selected item
   if( m_iCurSel >= 0 ) {
      CControlUI* pControl = GetItem(m_iCurSel);
      if( pControl != NULL ) {
         IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
         if( pListItem != NULL ) pListItem->Select(false);
      }
   }
   // Now figure out if the control can be selected
   // TODO: Redo old selected if failure
   CControlUI* pControl = GetItem(iIndex);
   if( pControl == NULL ) return false;
   if( !pControl->IsVisible() ) return false;
   if( !pControl->IsEnabled() ) return false;
   IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
   if( pListItem == NULL ) return false;
   m_iCurSel = iIndex;
   if( !pListItem->Select(true) ) {
      m_iCurSel = -1;
      return false;
   }
   pControl->SetFocus();
   if( m_pManager != NULL ) {
      m_pManager->SendNotify(pControl, _T("itemclick"));
      m_pManager->SendNotify(this, _T("itemselect"));
   }
   Invalidate();
   return true;
}
Exemple #3
0
	bool CComboUI::SelectItem(int iIndex, bool bTakeFocus)
	{
		if( iIndex == m_iCurSel ) return true;
		int iOldSel = m_iCurSel;
		if( m_iCurSel >= 0 ) {
			CControlUI* pControl = static_cast<CControlUI*>(m_items[m_iCurSel]);
			if( !pControl ) return false;
			IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
			if( pListItem != NULL ) pListItem->Select(false);
			m_iCurSel = -1;
		}
		if( iIndex < 0 ) return false;
		if( m_items.GetSize() == 0 ) return false;
		if( iIndex >= m_items.GetSize() ) iIndex = m_items.GetSize() - 1;
		CControlUI* pControl = static_cast<CControlUI*>(m_items[iIndex]);
		if( !pControl || !pControl->IsEnabled() ) return false;
		IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
		if( pListItem == NULL ) return false;
		m_iCurSel = iIndex;
		if( m_pWindow != NULL || bTakeFocus ) pControl->SetFocus();
		pListItem->Select(true);
		if( m_pManager != NULL ) m_pManager->SendNotify(this, DUI_MSGTYPE_ITEMSELECT, m_iCurSel, iOldSel);
		Invalidate();

		return true;
	}
Exemple #4
0
bool CNavigatorPanelUI::SelectItem(int iIndex)
{
    if (iIndex == m_iCurSel) return true;
    if (m_iCurSel >= 0) {
        CControlUI* pControl = GetItem(m_iCurSel);
        IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
        if (pListItem != NULL) pListItem->Select(false);
    }
    m_iCurSel = iIndex;
    if (m_iCurSel >= 0) {
        CControlUI* pControl = GetItem(m_iCurSel);
        IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
        if (pListItem == NULL) return false;
        pListItem->Select(true);
        if (m_pManager != NULL) m_pManager->SendNotify(pControl, _T("itemclick"));
    }
    if (m_pManager != NULL) m_pManager->SendNotify(this, _T("itemselect"));
    Invalidate();
    return true;
}
Exemple #5
0
bool NavigatorPanelUI::SelectItem(int idx)
{
    if (idx == m_curSel)  return true;
    if (m_curSel >= 0)  {
        ControlUI* ctrl = GetItem(m_curSel);
        IListItemUI* listItem = static_cast<IListItemUI*>(ctrl->GetInterface("ListItem"));
        if (listItem != NULL)  listItem->Select(false);
    }
    m_curSel = idx;
    if (m_curSel >= 0)  {
        ControlUI* ctrl = GetItem(m_curSel);
        IListItemUI* listItem = static_cast<IListItemUI*>(ctrl->GetInterface("ListItem"));
        if (listItem == NULL)  return false;
        listItem->Select(true);
        if (m_mgr != NULL)  m_mgr->SendNotify(ctrl, "itemclick");
    }
    if (m_mgr != NULL)  m_mgr->SendNotify(this, "itemselect");
    Invalidate();
    return true;
}
Exemple #6
0
bool CUIComboBox::SetCurSel(int iIndex)
{
   if( iIndex == m_iCurSel ) return true;
   if( m_iCurSel >= 0 ) {
      CUIControl* pControl = static_cast<CUIControl*>(m_items[m_iCurSel]);
      IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
      if( pListItem != NULL ) pListItem->Select(false);
      m_iCurSel = -1;
   }
   if( m_items.GetSize() == 0 ) return false;
   if( iIndex < 0 ) iIndex = 0;
   if( iIndex >= m_items.GetSize() ) iIndex = m_items.GetSize() - 1;
   CUIControl* pControl = static_cast<CUIControl*>(m_items[iIndex]);
   if( !pControl->IsVisible() ) return false;
   if( !pControl->IsEnabled() ) return false;
   IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
   if( pListItem == NULL ) return false;
   m_iCurSel = iIndex;
   pControl->SetFocus();
   pListItem->Select(true);

   CUIContainer* pContainer = dynamic_cast<CUIContainer*>(pListItem->GetOwner());
   if (pContainer)
   {
	   RECT rcItem = pControl->GetPos();
	   RECT rcList = pContainer->GetPos();
	   int iPos = pContainer->GetScrollPos();
	   if( rcItem.top < rcList.top || rcItem.bottom > rcList.bottom )
	   {
		   int dx = 0;
		   if( rcItem.top < rcList.top ) dx = rcItem.top - rcList.top;
		   if( rcItem.bottom > rcList.bottom ) dx = rcItem.bottom - rcList.bottom;
			pContainer->SetScrollPos(pContainer->GetScrollPos() + dx);
	   }

   }

   Invalidate();
   return true;
}
Exemple #7
0
bool CGroupsUI::SelectItem(int iIndex, bool bTakeFocus)
{
	if( iIndex == m_iCurSel ) return true;

	// We should first unselect the currently selected item
	if( m_iCurSel >= 0 ) {
		CControlUI* pControl = GetItemAt(m_iCurSel);
		if( pControl != NULL) {
			IListItemUI* pListItem = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem")));
			if( pListItem != NULL )
			{
				CListContainerElementUI* pFriendListItem = static_cast<CListContainerElementUI*>(pControl);
				Node* node = (Node*)pControl->GetTag();
				if ((pFriendListItem != NULL) && (node != NULL) && !node->folder())
				{
// 					pFriendListItem->SetFixedHeight(kFriendListItemNormalHeight);
// 					CContainerUI* pOperatorPannel = static_cast<CContainerUI*>(paint_manager_.FindSubControlByName(pFriendListItem, kOperatorPannelControlName));
// 					if (pOperatorPannel != NULL)
// 					{
// 						pOperatorPannel->SetVisible(false);
// 					}
				}
				pListItem->Select(false);
			}
		}

		m_iCurSel = -1;
	}

	if( iIndex < 0 )
		return false;

	if (!__super::SelectItem(iIndex, bTakeFocus))
		return false;

	CControlUI* pControl = GetItemAt(m_iCurSel);
	if( pControl != NULL) {
		CListContainerElementUI* pFriendListItem = static_cast<CListContainerElementUI*>(pControl);
		Node* node = (Node*)pControl->GetTag();
		if ((pFriendListItem != NULL) && (node != NULL) && !node->folder())
		{
// 			pFriendListItem->SetFixedHeight(kFriendListItemSelectedHeight);
// 			CContainerUI* pOperatorPannel = static_cast<CContainerUI*>(paint_manager_.FindSubControlByName(pFriendListItem, kOperatorPannelControlName));
// 			if (pOperatorPannel != NULL)
// 			{
// 				pOperatorPannel->SetVisible(true);
// 			}
			//pFriendListItem->SetBkImage()
		}
	}
	return true;
}