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; }
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; }
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; }
// bool ViCbIsEnabled(VApiHandle hWnd) SQInteger ViCbIsEnabled(HSQUIRRELVM v) { SQInteger nargs = sq_gettop(v); SQInteger Handle = 0; CControlUI* pCtrl = NULL; SQBool bRet = FALSE; if (!v || 1 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} sq_getinteger(v, 2, &Handle); pCtrl = QiHwHandleToCtrl(Handle); if (!pCtrl) {goto _Exit_;} bRet = pCtrl->IsEnabled(); _Exit_: sq_pushbool(v, bRet); return 1; }