Add column parameter to wxListCtrl::GetItemText().
Allow retrieving the text from columns other than the first one directly. Add implementations for MSW and generic versions, documentation and a unit test. Closes #11597. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64281 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -724,6 +724,7 @@ All (GUI):
|
|||||||
- Added wxGenericStaticBitmap suitable for display of large bitmaps.
|
- Added wxGenericStaticBitmap suitable for display of large bitmaps.
|
||||||
- Support wxListCtrl::GetViewRect() in report view too.
|
- Support wxListCtrl::GetViewRect() in report view too.
|
||||||
- Implement wxListCtrl::GetSubItemRect() in generic version (David Barnard).
|
- Implement wxListCtrl::GetSubItemRect() in generic version (David Barnard).
|
||||||
|
- Add column parameter to wxListCtrl::GetItemText() (Allann Jones).
|
||||||
- Added wxVListBox::GetItemRect() (Javier Urien).
|
- Added wxVListBox::GetItemRect() (Javier Urien).
|
||||||
- Show busy cursor in wxLaunchDefaultBrowser and add wxBROWSER_NOBUSYCURSOR.
|
- Show busy cursor in wxLaunchDefaultBrowser and add wxBROWSER_NOBUSYCURSOR.
|
||||||
- Added wxFlexGridSizer::Is{Row,Col}Growable() (Marcin Wojdyr).
|
- Added wxFlexGridSizer::Is{Row,Col}Growable() (Marcin Wojdyr).
|
||||||
|
@@ -79,7 +79,7 @@ public:
|
|||||||
bool SetItemState( long item, long state, long stateMask);
|
bool SetItemState( long item, long state, long stateMask);
|
||||||
bool SetItemImage( long item, int image, int selImage = -1 );
|
bool SetItemImage( long item, int image, int selImage = -1 );
|
||||||
bool SetItemColumnImage( long item, long column, int image );
|
bool SetItemColumnImage( long item, long column, int image );
|
||||||
wxString GetItemText( long item ) const;
|
wxString GetItemText( long item, int col = 0 ) const;
|
||||||
void SetItemText( long item, const wxString& str );
|
void SetItemText( long item, const wxString& str );
|
||||||
wxUIntPtr GetItemData( long item ) const;
|
wxUIntPtr GetItemData( long item ) const;
|
||||||
bool SetItemPtrData(long item, wxUIntPtr data);
|
bool SetItemPtrData(long item, wxUIntPtr data);
|
||||||
|
@@ -173,7 +173,7 @@ public:
|
|||||||
bool SetItemColumnImage(long item, long column, int image);
|
bool SetItemColumnImage(long item, long column, int image);
|
||||||
|
|
||||||
// Gets the item text
|
// Gets the item text
|
||||||
wxString GetItemText(long item) const;
|
wxString GetItemText(long item, int col = 0) const;
|
||||||
|
|
||||||
// Sets the item text
|
// Sets the item text
|
||||||
void SetItemText(long item, const wxString& str);
|
void SetItemText(long item, const wxString& str);
|
||||||
|
@@ -449,8 +449,14 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Gets the item text for this item.
|
Gets the item text for this item.
|
||||||
|
|
||||||
|
@param item
|
||||||
|
Item (zero-based) index.
|
||||||
|
@param col
|
||||||
|
Item column (zero-based) index. Column 0 is the default. This
|
||||||
|
parameter is new in wxWidgets 2.9.1.
|
||||||
*/
|
*/
|
||||||
wxString GetItemText(long item) const;
|
wxString GetItemText(long item, int col = 0) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the colour for this item.
|
Returns the colour for this item.
|
||||||
|
@@ -4562,9 +4562,9 @@ wxGenericListCtrl::SetItemColumnImage( long item, long column, int image )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxGenericListCtrl::GetItemText( long item ) const
|
wxString wxGenericListCtrl::GetItemText( long item, int col ) const
|
||||||
{
|
{
|
||||||
return m_mainWin->GetItemText(item);
|
return m_mainWin->GetItemText(item, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGenericListCtrl::SetItemText( long item, const wxString& str )
|
void wxGenericListCtrl::SetItemText( long item, const wxString& str )
|
||||||
|
@@ -1031,12 +1031,13 @@ bool wxListCtrl::SetItemColumnImage(long item, long column, int image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gets the item text
|
// Gets the item text
|
||||||
wxString wxListCtrl::GetItemText(long item) const
|
wxString wxListCtrl::GetItemText(long item, int col) const
|
||||||
{
|
{
|
||||||
wxListItem info;
|
wxListItem info;
|
||||||
|
|
||||||
info.m_mask = wxLIST_MASK_TEXT;
|
info.m_mask = wxLIST_MASK_TEXT;
|
||||||
info.m_itemId = item;
|
info.m_itemId = item;
|
||||||
|
info.m_col = col;
|
||||||
|
|
||||||
if (!GetItem(info))
|
if (!GetItem(info))
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
@@ -41,6 +41,7 @@ private:
|
|||||||
CPPUNIT_TEST( ColumnsOrder );
|
CPPUNIT_TEST( ColumnsOrder );
|
||||||
#endif // wxHAS_LISTCTRL_COLUMN_ORDER
|
#endif // wxHAS_LISTCTRL_COLUMN_ORDER
|
||||||
CPPUNIT_TEST( ItemRect );
|
CPPUNIT_TEST( ItemRect );
|
||||||
|
CPPUNIT_TEST( ItemText );
|
||||||
CPPUNIT_TEST( ChangeMode );
|
CPPUNIT_TEST( ChangeMode );
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
@@ -48,6 +49,7 @@ private:
|
|||||||
void ColumnsOrder();
|
void ColumnsOrder();
|
||||||
#endif // wxHAS_LISTCTRL_COLUMN_ORDER
|
#endif // wxHAS_LISTCTRL_COLUMN_ORDER
|
||||||
void ItemRect();
|
void ItemRect();
|
||||||
|
void ItemText();
|
||||||
void ChangeMode();
|
void ChangeMode();
|
||||||
|
|
||||||
wxListCtrl *m_list;
|
wxListCtrl *m_list;
|
||||||
@@ -178,6 +180,19 @@ void ListCtrlTestCase::ItemRect()
|
|||||||
WX_ASSERT_FAILS_WITH_ASSERT( m_list->GetSubItemRect(0, 3, r) );
|
WX_ASSERT_FAILS_WITH_ASSERT( m_list->GetSubItemRect(0, 3, r) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListCtrlTestCase::ItemText()
|
||||||
|
{
|
||||||
|
m_list->InsertColumn(0, "First");
|
||||||
|
m_list->InsertColumn(1, "Second");
|
||||||
|
|
||||||
|
m_list->InsertItem(0, "0,0");
|
||||||
|
CPPUNIT_ASSERT_EQUAL( "0,0", m_list->GetItemText(0) );
|
||||||
|
CPPUNIT_ASSERT_EQUAL( "", m_list->GetItemText(0, 1) );
|
||||||
|
|
||||||
|
m_list->SetItem(0, 1, "0,1");
|
||||||
|
CPPUNIT_ASSERT_EQUAL( "0,1", m_list->GetItemText(0, 1) );
|
||||||
|
}
|
||||||
|
|
||||||
void ListCtrlTestCase::ChangeMode()
|
void ListCtrlTestCase::ChangeMode()
|
||||||
{
|
{
|
||||||
m_list->InsertColumn(0, "Header");
|
m_list->InsertColumn(0, "Header");
|
||||||
|
Reference in New Issue
Block a user