本文整理汇总了C++中wxListCtrl::GetItemCount方法的典型用法代码示例。如果您正苦于以下问题:C++ wxListCtrl::GetItemCount方法的具体用法?C++ wxListCtrl::GetItemCount怎么用?C++ wxListCtrl::GetItemCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxListCtrl
的用法示例。
在下文中一共展示了wxListCtrl::GetItemCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxListCtrlGetSelection
// Find the selection
long wxListCtrlGetSelection(wxListCtrl& listCtrl)
{
long n = listCtrl.GetItemCount();
long i;
for (i = 0; i < n; i++)
{
if (listCtrl.GetItemState(i, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED)
{
return i;
}
}
return -1;
}
示例2: wxListCtrlSelectItem
// Select the given item
void wxListCtrlSelectItem(wxListCtrl& listCtrl, long sel, bool deselectOthers)
{
long n = listCtrl.GetItemCount();
long i;
if (deselectOthers)
{
for (i = 0; i < n; i++)
{
if (listCtrl.GetItemState(i, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED)
{
listCtrl.SetItemState(i, wxLIST_STATE_SELECTED, 0);
}
}
}
listCtrl.SetItemState(sel, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
示例3: ConvertViewCtrlToTrackData
void ConvertViewCtrlToTrackData(const wxListCtrl &listctrl, const std::map< wxString, long > &mapping, std::vector<lfmt::TrackData> &tracklist, wxDateTime offset)
{
auto row_count = listctrl.GetItemCount();
if (row_count < 1)
return;
// grab column indices from string-long-map which we have just for purpose of dynamic indices (ie. changing column order is easy)
auto idx_artist = mapping.find("Artist")->second;
auto idx_tname = mapping.find("Trackname")->second;
auto idx_album = mapping.find("Album")->second;
auto idx_time = mapping.find("Time")->second;
wxDateTime last_time = offset;
// last track on the list is the most recentry track that was listened to;
// moving up the list successive tracks will get earlier times
for (int row = row_count-1; row >= 0; --row)
{
lfmt::TrackData td;
// is there a better way of getting the info out of the listviewctrl?
// it's questionable if I would have gotten it without the wxforum :(
wxListItem item;
item.SetId(row);
item.SetMask(wxLIST_MASK_TEXT);
// "unrolled loop" for all columns
item.SetColumn(idx_artist);
listctrl.GetItem(item);
td.artist = item.GetText();
item.SetColumn(idx_tname);
listctrl.GetItem(item);
td.trackname = item.GetText();
item.SetColumn(idx_album);
listctrl.GetItem(item);
td.album = item.GetText();
td.timestamp = last_time.GetTicks(); // set time *before* calculating the descendant
item.SetColumn(idx_time);
listctrl.GetItem(item);
{
// now calculate 'last_time' offset according to playtime of the current track
// defaults to 3 minutes if we don't know the track's length
wxArrayString time_str = wxStringTokenize(item.GetText(), ":");
long minutes, seconds;
bool success = true;
success &= time_str[0].ToLong(&minutes);
success &= time_str[1].ToLong(&seconds);
if (success)
last_time -= wxTimeSpan(0, minutes, seconds);
else
{
wxLogWarning("Could not parse timespan " + item.GetText() + ". Assuming track length of 3 minutes.");
last_time -= wxTimeSpan(0, 3, 0);
}
}
tracklist.push_back(td);
wxLogDebug("Converted track " + td.ToString() + " from row %d.", row);
}
}
示例4: InitPage
void SjMyMusicConfigPage::InitPage(const wxString& selSourceUrl)
{
// create index list
m_listOfSources.Clear();
m_listOfSources.DeleteContents(TRUE);
SjModuleList* list = g_mainFrame->m_moduleSystem.GetModules(SJ_MODULETYPE_SCANNER);
wxASSERT(list);
SjModuleList::Node* moduleNode = list->GetFirst();
SjScannerModule* scannerModule;
while( moduleNode )
{
scannerModule = (SjScannerModule*)moduleNode->GetData();
wxASSERT(scannerModule);
wxASSERT(scannerModule->IsLoaded());
long sourceCount = scannerModule->GetSourceCount();
long currSourceIndex;
for( currSourceIndex = 0; currSourceIndex < sourceCount; currSourceIndex++ )
{
SjSettingsSourceItem* item = new SjSettingsSourceItem(scannerModule, currSourceIndex, scannerModule->GetSourceUrl(currSourceIndex), scannerModule->GetSourceIcon(currSourceIndex));
m_listOfSources.Append(item);
}
// next
moduleNode = moduleNode->GetNext();
}
// get list control
m_listCtrl->Freeze();
m_listCtrl->DeleteAllItems();
// go through all search directories
SjSettingsSourceItem* item;
SjSettingsSourceItemList::Node* itemnode = m_listOfSources.GetFirst();
int i = 0;
wxString sourceNotes;
while( itemnode )
{
item = itemnode->GetData();
wxASSERT(item);
wxListItem listitem;
listitem.m_mask = wxLIST_MASK_IMAGE | wxLIST_MASK_TEXT | wxLIST_MASK_DATA;
listitem.m_itemId = i;
listitem.m_text = item->GetUrl();
listitem.SetData((void*)item);
listitem.m_image = item->GetScannerModule()->GetSourceIcon(item->GetIndex());
sourceNotes = item->GetScannerModule()->GetSourceNotes(item->GetIndex());
if( !sourceNotes.IsEmpty() )
{
listitem.m_text.Append(" (");
listitem.m_text.Append(sourceNotes);
listitem.m_text.Append(')');
}
m_listCtrl->InsertItem(listitem);
itemnode = itemnode->GetNext();
i++;
}
m_listCtrl->SortItems(ListCtrlCompareFunction, m_currSortCol);
m_listCtrl->Thaw();
// select the correct item
// (should be done after SortItems() on GTK this may remove the selection ...)
int i_cnt = m_listCtrl->GetItemCount();
for( i = 0; i < i_cnt; i ++ )
{
item = (SjSettingsSourceItem*)m_listCtrl->GetItemData(i);
if( item->GetUrl() == selSourceUrl ) {
m_listCtrl->SetItemState(i, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
break;
}
}
UpdateButtons();
}