void PlayerListWnd::PlayerSelectionChanged(const GG::ListBox::SelectionSet& rows) { // mark as selected all PlayerDataPanel that are in \a rows and mark as not // selected all PlayerDataPanel that aren't in \a rows for (GG::ListBox::iterator it = m_player_list->begin(); it != m_player_list->end(); ++it) { bool select_this_row = (rows.find(it) != rows.end()); GG::ListBox::Row* row = *it; if (!row) { ErrorLogger() << "PlayerListWnd::PlayerSelectionChanged couldn't get row"; continue; } if (row->empty()) { ErrorLogger() << "PlayerListWnd::PlayerSelectionChanged got empty row"; continue; } GG::Control* control = !row->empty() ? row->at(0) : nullptr; if (!control) { ErrorLogger() << "PlayerListWnd::PlayerSelectionChanged couldn't get control from row"; continue; } PlayerDataPanel* data_panel = dynamic_cast<PlayerDataPanel*>(control); if (!data_panel) { ErrorLogger() << "PlayerListWnd::PlayerSelectionChanged couldn't get PlayerDataPanel from control"; continue; } data_panel->Select(select_this_row); } SelectedPlayersChangedSignal(); }
void ServerConnectWnd::PopulateServerList() { m_servers_lb->Clear(); for (ClientNetworking::ServerList::iterator it = m_LAN_servers.begin(); it != m_LAN_servers.end(); ++it) { GG::ListBox::Row* row = new GG::ListBox::Row; row->push_back(it->second, ClientUI::GetFont(), ClientUI::TextColor()); m_servers_lb->Insert(row); } }
ListBox::Row* DefaultRowFactoryFunction(const adobe::dictionary_t& parameters) { std::string drag_drop_data_type; adobe::get_value(parameters, adobe::static_name_t("drag_drop_data_type"), drag_drop_data_type); GG::ListBox::Row* retval = new GG::ListBox::Row(GG::X1, adobe::implementation::RowHeight(), drag_drop_data_type); std::string name; adobe::get_value(parameters, adobe::static_name_t("name"), name); Clr color; adobe::implementation::get_color(parameters, adobe::static_name_t("color"), color); retval->push_back( adobe::implementation::Factory().NewTextControl(GG::X0, GG::Y0, name, adobe::implementation::DefaultFont(), color, GG::FORMAT_LEFT) ); return retval; }
void QueueListBox::Render() { ListBox::Render(); // render drop point line if (m_show_drop_point && m_order_issuing_enabled) { GG::ListBox::Row* row = *(m_drop_point == end() ? --end() : m_drop_point); if (!row) return; GG::Pt ul = row->UpperLeft(), lr = row->LowerRight(); if (m_drop_point == end()) ul.y = lr.y; if (!row->empty()) { GG::Control* panel = (*row)[0]; ul.x = panel->UpperLeft().x; lr.x = panel->LowerRight().x; } GG::FlatRectangle(GG::Pt(ul.x, ul.y - 1), GG::Pt(lr.x, ul.y), GG::CLR_ZERO, GG::CLR_WHITE, 1); } }
GG::ListBox::Row* item_to_row(const dictionary_t& item, const row_factory_t* row_factory, const GG::Clr& default_item_color) { const bool contains_color = item.count(static_name_t("color")); dictionary_t colorful_dictionary; if (!contains_color) { colorful_dictionary = item; colorful_dictionary[static_name_t("color")] = any_regular_t(default_item_color); } const dictionary_t& dictionary = contains_color ? item : colorful_dictionary; name_t type; get_value(dictionary, static_name_t("type"), type); row_factory_t::const_iterator it; GG::ListBox::Row* retval = 0; if (row_factory && (it = row_factory->find(type)) != row_factory->end()) retval = it->second(dictionary); else retval = GG::DefaultRowFactoryFunction(dictionary); retval->SetItem(item); return retval; }