// the heading text is in the format of "text,width,format;text,width,format;..." BOOL CReportCtrl::SetColumnHeader(const CString& strHeadings) { DeleteAllItems(); DeleteAllColumns(); EndEdit(TRUE); BOOL bInserted = FALSE; CStringArray aLong, aShort; _StringSplit(strHeadings, aLong, _T(';')); for (int i = 0; i < aLong.GetSize(); i++) { _StringSplit(aLong[i], aShort, _T(',')); if (aShort.GetSize() > 0) { const int WIDTH = aShort.GetSize() > 1 ? _ttoi(aShort[1]) : 100; int nFormat = aShort.GetSize() > 2 ? _ttoi(aShort[2]) : 0; if (nFormat == 1) nFormat = LVCFMT_CENTER; else if (nFormat == 2) nFormat = LVCFMT_RIGHT; else nFormat = LVCFMT_LEFT; bInserted |= (InsertColumn(GetColumnCount(), aShort[0], nFormat, WIDTH) >= 0); } } return bInserted; }
void PoeditListCtrl::CreateColumns() { DeleteAllColumns(); int curr = 0; m_colSource = (int)InsertColumn(curr++, _("Source text")); if (m_catalog && m_catalog->HasCapability(Catalog::Cap::Translations)) m_colTrans = (int)InsertColumn(curr++, _("Translation")); else m_colTrans = -1; if (m_displayIDs) m_colId = (int)InsertColumn(curr++, _("ID"), wxLIST_FORMAT_RIGHT); else m_colId = -1; #ifdef __WXMSW__ if (m_appIsRTL) { // another wx quirk: if we truly need left alignment, we must lie under RTL locales wxListItem colInfoOrig; colInfoOrig.SetAlign(wxLIST_FORMAT_RIGHT); SetColumn(m_colSource, colInfoOrig); } #endif SizeColumns(); }
void CPageDocuments::DisplayShips(int index) { CString info; m_list.DeleteAllItems(); DeleteAllColumns(); m_list.InsertColumn(0 , "船舰名字" , LVCFMT_LEFT , 100); m_list.InsertColumn(1 , "建造金属" , LVCFMT_LEFT , 80); m_list.InsertColumn(2 , "建造晶体" , LVCFMT_LEFT , 80); m_list.InsertColumn(3 , "建造重氢" , LVCFMT_LEFT , 80); m_list.InsertColumn(4 , "建造时间" , LVCFMT_LEFT , 80); m_list.InsertColumn(5 , "攻击能力" , LVCFMT_LEFT , 80); m_list.InsertColumn(6 , "运载能力" , LVCFMT_LEFT , 80); m_list.InsertColumn(7 , "飞行速度" , LVCFMT_LEFT , 80); m_list.InsertColumn(8 , "技术需求" , LVCFMT_LEFT , 250); for(int i = 0 ; i < BOAT_MAX ; ++i) { info.Format("%s" , BOATS_NAME[i]); m_list.InsertItem(i , info); //metal info.Format("%d" , BOATS_RESOURCE_NEED_BASE[i][0] ); m_list.SetItemText(i , 1 , info); //crystal info.Format("%d" , BOATS_RESOURCE_NEED_BASE[i][1] ); m_list.SetItemText(i , 2 , info); //diplogen info.Format("%d" , BOATS_RESOURCE_NEED_BASE[i][2] ); m_list.SetItemText(i , 3 , info); //time double t = get_boat_produce_seconds( GetDataPtr()->GetBuildingLevel(FACTORY_BUILDING_BOATYARD), //shipyard level GetDataPtr()->GetBuildingLevel(FACTORY_BUILDING_NANITE), //nanitefactory level BOATS_RESOURCE_NEED_BASE[i][0] , BOATS_RESOURCE_NEED_BASE[i][1], 1.0); HighFrequencyElapsedTimer timer; timer.Init(t * 1000); m_list.SetItemText(i , 4 , timer.ToCString()); //attack force info.Format("%d" , UINT(SHIP_ATTACK_FORCE_BASE[i] * (1 + 0.1 * GetDataPtr()->GetResearchLevel(RESEARCH_WEAPON))) ); m_list.SetItemText(i , 5 , info); //transfer capacity force info.Format("%d" , SHIP_TRANSFER_CAPACITY[i] ); m_list.SetItemText(i , 6 , info); //speed info.Format("%d" , kernel_.GetShipSpeed(ITEM_TYPE(i) , 0)); m_list.SetItemText(i , 7 , info); //tech needed m_list.SetItemText(i , 8 , Boats_Entry(i)->GetTechNeeded()); } }
void CPageDocuments::DisplayDummy(int index) { assert(index == ROOT_FACTORY || index == ROOT_RESEARCH); CString info; m_list.DeleteAllItems(); DeleteAllColumns(); if(index == ROOT_FACTORY) { m_list.InsertColumn(0 , "帝国生产工厂" , LVCFMT_LEFT , 100); m_list.InsertColumn(1 , "技术需求" , LVCFMT_LEFT , 180); m_list.InsertColumn(2 , "描述" , LVCFMT_LEFT , 530); for(int i = 0 ; i < building_keeper_->Size() ; ++i) { m_list.InsertItem(i , Buildings_Entry(i)->GetName()); m_list.SetItemText(i , 1 , Buildings_Entry(i)->GetCanlevelString()); m_list.SetItemText(i , 2 , Buildings_Entry(i)->GetSimpleDisp()); } } else if(index == ROOT_RESEARCH) { m_list.InsertColumn(0 , "帝国科学研究" , LVCFMT_LEFT , 90); m_list.InsertColumn(1 , "技术需求" , LVCFMT_LEFT , 180); m_list.InsertColumn(2 , "描述" , LVCFMT_LEFT , 650); for(int i = 0 ; i < research_keeper_->Size() ; ++i) { m_list.InsertItem(i , Researchs_Entry(i)->GetName()); m_list.SetItemText(i , 1 , Researchs_Entry(i)->GetTechNeeded()); m_list.SetItemText(i , 2 , Researchs_Entry(i)->GetSimpleDisp()); } } }
void PoeditListCtrl::CreateColumns() { DeleteAllColumns(); InsertColumn(0, _("Source text")); InsertColumn(1, _("Translation")); if (m_displayLines) InsertColumn(2, _("Line"), wxLIST_FORMAT_RIGHT); SizeColumns(); }
void CMyListCtrl::InitList(CString csParams, int nCount) { DeleteAllColumns(); SetExtendedStyle(GetExtendedStyle() |LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT |LVS_EX_SUBITEMIMAGES); SetParamCount(nCount); SetHead(csParams); AutoSize(); }
//设置ListHead int CMyListCtrl::SetHead(CString csParams) { DeleteAllColumns(); CString csParam; for (int i = 0; i < m_nParam; i++) { AfxExtractSubString(csParam, csParams, i, '|'); if (InsertColumn(i, csParam) == -1) { return -1; } } return 1; }
//*************************************************************************** BOOL CBCGPDAOGridCtrl::Close () { RemoveAll (); DeleteAllColumns (); try { if (m_pRecordSet != NULL) { ASSERT_VALID(m_pRecordSet); if (m_pRecordSet->IsOpen ()) { m_pRecordSet->Close (); } delete m_pRecordSet; m_pRecordSet = NULL; } if (m_pDataBase != NULL) { ASSERT_VALID (m_pDataBase); if (m_pDataBase->IsOpen ()) { m_pDataBase->Close (); } delete m_pDataBase; m_pDataBase = NULL; } } catch (CDaoException* pEx) { OnDaoException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
void CPageDocuments::DisplayResearch(int index) { assert(index >= 0 && index < RESEARCH_MAX); CString info; m_list.DeleteAllItems(); DeleteAllColumns(); m_list.InsertColumn(0 , "等级" , LVCFMT_LEFT , 40); m_list.InsertColumn(1 , "升级金属" , LVCFMT_LEFT , 130); m_list.InsertColumn(2 , "升级晶体" , LVCFMT_LEFT , 130); m_list.InsertColumn(3 , "升级重氢" , LVCFMT_LEFT , 130); m_list.InsertColumn(4 , "升级时间" , LVCFMT_LEFT , 130); for(int i = 0 ; i < MAX_LEVEL ; ++i) { info.Format("%d" , i); m_list.InsertItem(i , info); //metal info.Format("%.0f" , get_research_upgrade_resource(RESEARCH_RESOURCE_NEED_BASE[index][0] , i) ); m_list.SetItemText(i , 1 , info); //crystal info.Format("%.0f" , get_research_upgrade_resource(RESEARCH_RESOURCE_NEED_BASE[index][1] , i) ); m_list.SetItemText(i , 2 , info); //diplogen info.Format("%.0f" , get_research_upgrade_resource(RESEARCH_RESOURCE_NEED_BASE[index][2] , i)); m_list.SetItemText(i , 3 , info); //time double t = get_research_upgrade_seconds( GetDataPtr()->GetBuildingLevel(FACTORY_BUILDING_LAB), //LabFactory level GetDataPtr()->GetBuildingLevel(FACTORY_BUILDING_NANITE), //nanitefactory level get_research_upgrade_resource(RESEARCH_RESOURCE_NEED_BASE[index][0] , i) , get_research_upgrade_resource(RESEARCH_RESOURCE_NEED_BASE[index][1] , i) , 1.0); ElapsedTimer timer; timer.Init(t); m_list.SetItemText(i , 4 , timer.ToCString()); } m_list.SetItemBkColor(Researchs_Entry(index)->GetLevel() , -1 , RGB(0 , 255 , 0)); }
void PoeditListCtrl::CreateColumns() { DeleteAllColumns(); InsertColumn(0, _("Source text")); InsertColumn(1, _("Translation")); if (m_displayIDs) InsertColumn(2, _("ID"), wxLIST_FORMAT_RIGHT); #ifdef __WXMSW__ if (m_appIsRTL) { // another wx quirk: if we truly need left alignment, we must lie under RTL locales wxListItem colInfoOrig; colInfoOrig.SetAlign(wxLIST_FORMAT_RIGHT); SetColumn(0, colInfoOrig); } #endif SizeColumns(); }
void LstOdaServerList::SetupServerListColumns() { wxFileConfig ConfigInfo; wxInt32 WidthName, WidthPing, WidthPlayers, WidthWads, WidthMap, WidthType; wxInt32 WidthIwad, WidthAddress; DeleteAllColumns(); // Read in the column widths ConfigInfo.Read(wxT("ServerListWidthName"), &WidthName, 150); ConfigInfo.Read(wxT("ServerListWidthPing"), &WidthPing, 60); ConfigInfo.Read(wxT("ServerListWidthPlayers"), &WidthPlayers, 80); ConfigInfo.Read(wxT("ServerListWidthWads"), &WidthWads, 150); ConfigInfo.Read(wxT("ServerListWidthMap"), &WidthMap, 60); ConfigInfo.Read(wxT("ServerListWidthType"), &WidthType, 80); ConfigInfo.Read(wxT("ServerListWidthIwad"), &WidthIwad, 100); ConfigInfo.Read(wxT("ServerListWidthAddress"), &WidthAddress, 130); // set up the list columns InsertColumn(serverlist_field_name, wxT("Server name"), wxLIST_FORMAT_LEFT, WidthName); InsertColumn(serverlist_field_ping, wxT("Ping"), wxLIST_FORMAT_LEFT, WidthPing); InsertColumn(serverlist_field_players, wxT("Players"), wxLIST_FORMAT_LEFT, WidthPlayers); InsertColumn(serverlist_field_wads, wxT("WADs"), wxLIST_FORMAT_LEFT, WidthWads); InsertColumn(serverlist_field_map, wxT("Map"), wxLIST_FORMAT_LEFT, WidthMap); InsertColumn(serverlist_field_type, wxT("Type"), wxLIST_FORMAT_LEFT, WidthType); InsertColumn(serverlist_field_iwad, wxT("Game IWAD"), wxLIST_FORMAT_LEFT, WidthIwad); InsertColumn(serverlist_field_address, wxT("Address : Port"), wxLIST_FORMAT_LEFT, WidthAddress); // Passworded server icon ImageList_Padlock = AddImageSmall(padlock_xpm); ImageList_PingGreen = AddImageSmall(wxXmlResource::Get()->LoadBitmap(wxT("bullet_green")).ConvertToImage()); ImageList_PingOrange = AddImageSmall(wxXmlResource::Get()->LoadBitmap(wxT("bullet_orange")).ConvertToImage()); ImageList_PingRed = AddImageSmall(wxXmlResource::Get()->LoadBitmap(wxT("bullet_red")).ConvertToImage()); ImageList_PingGray = AddImageSmall(wxXmlResource::Get()->LoadBitmap(wxT("bullet_gray")).ConvertToImage()); }
BOOL CBCGPODBCGridCtrl::OpenSQL (LPCTSTR lpszSQL) { ASSERT (lpszSQL != NULL); m_strSQL.Empty (); RemoveAll (); if (!m_bIsSorting) { DeleteAllColumns (); } if (m_pDataBase == NULL) { ASSERT (FALSE); return FALSE; } try { ASSERT_VALID (m_pDataBase); if (!m_pDataBase->IsOpen ()) { ASSERT (FALSE); return FALSE; } if (m_pRecordSet != NULL) { ASSERT_VALID (m_pRecordSet); if (m_pRecordSet->IsOpen ()) { m_pRecordSet->Close (); } delete m_pRecordSet; m_pRecordSet = NULL; } //--------------------------------------------------------- // Create a new record set and open it using SQL statement: //--------------------------------------------------------- m_pRecordSet = new CRecordset (m_pDataBase); if (!m_pRecordSet->Open (CRecordset::dynaset, lpszSQL)) { return FALSE; } int nColumns = 0; if (!m_bIsSorting) { //------------- // Add columns: //------------- CStringList lstField; if (!GetFieldList (lstField)) { return FALSE; } int nColumn = 0; for (POSITION pos = lstField.GetHeadPosition (); pos != NULL; nColumn++) { InsertColumn (nColumn, lstField.GetNext (pos), 50); } nColumns = (int) lstField.GetCount (); } else { nColumns = GetColumnCount (); } if (nColumns == 0) { // No columns AdjustLayout (); return TRUE; } //------------- // Add records: //------------- if (m_pRecordSet->IsEOF () && m_pRecordSet->IsBOF ()) { // The table is empty AdjustLayout (); return TRUE; } if (m_bVirtualMode) { while (!m_pRecordSet->IsEOF ()) { m_pRecordSet->MoveNext (); } SetVirtualRows (max (0, m_pRecordSet->GetRecordCount ())); } else { for (int nRow = 0; !m_pRecordSet->IsEOF (); m_pRecordSet->MoveNext (), nRow++) { CBCGPGridRow* pRow = CreateRow (nColumns); ASSERT_VALID (pRow); for (int nColumn = 0; nColumn < nColumns; nColumn++) { OnAddData (pRow, nColumn, nRow); } if (OnBeforeAddRow (pRow, nRow)) { AddRow (pRow, FALSE); } else { delete pRow; } } } m_strSQL = lpszSQL; AdjustLayout (); if (!m_pRecordSet->CanUpdate ()) { SetReadOnly (); } } catch (CDBException* pEx) { OnODBCException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
void LstOdaSrvDetails::LoadDetailsFromServer(Server &In) { DeleteAllItems(); DeleteAllColumns(); if (In.GotResponse() == false) return; // Begin adding data to the control // Set the initial background colour BGItemAlternator = *wxWHITE; InsertColumn(srvdetails_field_name, wxT(""), wxLIST_FORMAT_LEFT, 150); InsertColumn(srvdetails_field_value, wxT(""), wxLIST_FORMAT_LEFT, 150); // Version InsertLine(wxT("Version"), wxString::Format(wxT("%u.%u.%u-r%u"), In.Info.VersionMajor, In.Info.VersionMinor, In.Info.VersionPatch, In.Info.VersionRevision)); InsertLine(wxT("QP Version"), wxString::Format(wxT("%u"), In.Info.VersionProtocol)); // Status of the game InsertLine(wxT(""), wxT("")); InsertHeader(wxT("Game Status"), wxRED, wxWHITE); InsertLine(wxT("Time left"), wxString::Format(wxT("%u"), In.Info.TimeLeft)); if (In.Info.GameType == GT_TeamDeathmatch || In.Info.GameType == GT_CaptureTheFlag) { InsertLine(wxT("Score Limit"), wxString::Format(wxT("%u"), In.Info.ScoreLimit)); } // Patch (BEX/DEH) files InsertLine(wxT(""), wxT("")); InsertHeader(wxT("BEX/DEH Files"), wxRED, wxWHITE); if (In.Info.Patches.size() == 0) { InsertLine(wxT("None"), wxT("")); } else { size_t i = 0; size_t PatchesCount = In.Info.Patches.size(); wxString Current, Next; // A while loop is used to format this correctly while (i < PatchesCount) { Current = stdstr_towxstr(In.Info.Patches[i]); ++i; if (i < PatchesCount) Next = stdstr_towxstr(In.Info.Patches[i]); ++i; InsertLine(Current, Next); Current = wxT(""); Next = wxT(""); } } // Gameplay variables (Cvars, others) InsertLine(wxT(""), wxT("")); InsertHeader(wxT("Game Settings"), wxRED, wxWHITE); // Sort cvars ascending sort(In.Info.Cvars.begin(), In.Info.Cvars.end(), CvarCompare); for (size_t i = 0; i < In.Info.Cvars.size(); ++i) InsertLine(stdstr_towxstr(In.Info.Cvars[i].Name), stdstr_towxstr(In.Info.Cvars[i].Value)); // Resize the columns ResizeNameValueColumns(); }
void CPageDocuments::DisplayFactory(int index) { assert(index >= 0 && index < FACTORY_BUILDINGS_MAX); CString info; m_list.DeleteAllItems(); DeleteAllColumns(); m_list.InsertColumn(0 , "等级" , LVCFMT_LEFT , 40); m_list.InsertColumn(1 , "升级金属" , LVCFMT_LEFT , 90); m_list.InsertColumn(2 , "升级晶体" , LVCFMT_LEFT , 90); m_list.InsertColumn(3 , "升级重氢" , LVCFMT_LEFT , 90); m_list.InsertColumn(4 , "产生能量" , LVCFMT_LEFT , 90); m_list.InsertColumn(5 , "升级时间" , LVCFMT_LEFT , 100); m_list.InsertColumn(6 , "生产金属" , LVCFMT_LEFT , 90); m_list.InsertColumn(7 , "生产晶体" , LVCFMT_LEFT , 90); m_list.InsertColumn(8 , "生产重氢" , LVCFMT_LEFT , 90); for(int i = 0 ; i < MAX_LEVEL ; ++i) { info.Format("%d" , i); m_list.InsertItem(i , info); double m = 0.0; double c = 0.0; double d = 0.0; if(index > FACTORY_BUILDING_PRODUCE_MAX) { m = get_other_factory_upgrade_resource(FACTORY_DATA[index][FACTORY_TBL_N_METAL] , i); c = get_other_factory_upgrade_resource(FACTORY_DATA[index][FACTORY_TBL_N_CRYSTAL] , i); d = get_other_factory_upgrade_resource(FACTORY_DATA[index][FACTORY_TBL_N_DIPLOGEN] , i); } else { m = get_produce_factory_upgrade_resource(FACTORY_DATA[index][FACTORY_TBL_N_METAL] , i); c = get_produce_factory_upgrade_resource(FACTORY_DATA[index][FACTORY_TBL_N_CRYSTAL] , i); d = get_produce_factory_upgrade_resource(FACTORY_DATA[index][FACTORY_TBL_N_DIPLOGEN] , i); } //metal info.Format("%.0f" , m); m_list.SetItemText(i , 1 , info); //crystal info.Format("%.0f" , c); m_list.SetItemText(i , 2 , info); //diplogen info.Format("%.0f" , d); m_list.SetItemText(i , 3 , info); //sun power factory int p = get_produce_factory_consume_power(FACTORY_DATA[index][FACTORY_TBL_POWER] , i , 1.0); info.Format("%d" , p ); if(index != FACTORY_BUILDING_SUNPOWER && p != 0) { info.Format("-%d" , p ); } m_list.SetItemText(i , 4 , info); //time double t = get_factory_upgrade_seconds(GetDataPtr()->GetBuildingLevel(FACTORY_BUILDING_ROBOT) , GetDataPtr()->GetBuildingLevel(FACTORY_BUILDING_NANITE) , m , c , 1.0); ElapsedTimer timer; timer.Init(t); m_list.SetItemText(i , 5 , timer.ToCString()); //produce metal ulong a = 0; if(index == FACTORY_BUILDING_MINAL) a = 20; m = get_produce_factory_produce_resource_per_minute(a , FACTORY_DATA[index][FACTORY_TBL_P_METAL] , i , 1.0 , 1.0) * pow(2 , GetDataPtr()->GET_STAR_DOUBLE_RES_HERO()); info.Format("%.0f" , m * 60); m_list.SetItemText(i , 6 , info); //produce crystal a = 0; if(index == FACTORY_BUILDING_CRYSTAL) a = 10; c = get_produce_factory_produce_resource_per_minute(a , FACTORY_DATA[index][FACTORY_TBL_P_CRYSTAL] , i , 1.0 , 1.0) * pow(2 , GetDataPtr()->GET_STAR_DOUBLE_RES_HERO()); info.Format("%.0f" , c * 60); m_list.SetItemText(i , 7 , info); //produce diplogen d = (-0.002 * GetDataPtr()->STAR_TEMP() + 1.28 ) * get_produce_factory_produce_resource_per_minute(0 , FACTORY_DATA[index][FACTORY_TBL_P_DIPLOGEN] , i , 1.0 , 1.0) * pow(2 , GetDataPtr()->GET_STAR_DOUBLE_RES_HERO()); info.Format("%.0f" , d * 60); m_list.SetItemText(i , 8 , info); } m_list.SetItemBkColor(Buildings_Entry(index)->GetLevel() , -1 , RGB(0 , 255 , 0)); }