本文整理汇总了C++中wxListCtrl::GetItem方法的典型用法代码示例。如果您正苦于以下问题:C++ wxListCtrl::GetItem方法的具体用法?C++ wxListCtrl::GetItem怎么用?C++ wxListCtrl::GetItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxListCtrl
的用法示例。
在下文中一共展示了wxListCtrl::GetItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxListCtrlGetItemTextColumn
// Find the text of the list control item at the given column
wxString wxListCtrlGetItemTextColumn(wxListCtrl& listCtrl, long item, int col)
{
wxListItem listItem;
listItem.m_mask = wxLIST_MASK_TEXT;
listItem.m_itemId = item;
listItem.m_col = col;
if (listCtrl.GetItem(listItem))
return listItem.m_text;
else
return wxEmptyString;
}
示例2: 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);
}
}