LPCSTR CUIListBox::GetText(int idx) { if(idx==-1) return NULL; CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(GetItem(idx)); return item->GetText(); }
LPCSTR CUIListBox::GetSelectedText() { CUIWindow* w = GetSelected(); if(w) { CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(w); return item->GetText(); }else return NULL; }
void CUIKickPlayer::OnBtnOk() { CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(m_ui_players_list->GetSelected()); if (item) { string512 command; switch (mode) { case MODE_KICK: xr_sprintf(command, "cl_votestart kick %s", item->GetText()); break; case MODE_BAN: { xr_sprintf(command, "cl_votestart ban %s %d", item->GetText(), m_spin_ban_sec->Value()); }break; } Console->Execute (command); HideDialog (); } else return; }
CUIListBoxItem* CUIListBox::GetItemByText(LPCSTR txt) { for(WINDOW_LIST_it it = m_pad->GetChildWndList().begin(); m_pad->GetChildWndList().end()!=it; ++it) { CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(*it); if (item) { if (0 == xr_strcmp(item->GetText(), txt)) return item; } } return NULL; }
void CUIKickPlayer::SendMessage(CUIWindow* pWnd, s16 msg, void* pData) { if (LIST_ITEM_SELECT == msg && pWnd == m_ui_players_list) { CUIListBoxItem* itm = smart_cast<CUIListBoxItem*>(m_ui_players_list->GetSelected()); m_selected_item_text = itm->GetText(); } else if (BUTTON_CLICKED == msg) { if (pWnd == btn_ok) OnBtnOk (); else if (pWnd == btn_cancel) OnBtnCancel (); } }
float CUIListBox::GetLongestLength() { float len = 0; for(WINDOW_LIST_it it = m_pad->GetChildWndList().begin(); m_pad->GetChildWndList().end()!=it; ++it) { CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(*it); if (item) { float tmp_len = item->GetFont()->SizeOf_(item->GetText()); //all ok UI().ClientToScreenScaledWidth(tmp_len); if (tmp_len > len) len = tmp_len; } } return len; }