当前位置: 首页>>代码示例>>C++>>正文


C++ wxListCtrl::GetItem方法代码示例

本文整理汇总了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;
}
开发者ID:Joel397,项目名称:Ongoing_work_files,代码行数:13,代码来源:ecutils.cpp

示例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);
    }
}
开发者ID:sperrholz,项目名称:lfmt,代码行数:66,代码来源:lfmt_util.cpp


注:本文中的wxListCtrl::GetItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。