Applied Patch #1424869: Implement wxListCtrl::SetItemColumnImage

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37982 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2006-03-10 21:26:59 +00:00
parent b4deaacba3
commit 06db67bcb0
14 changed files with 69 additions and 5 deletions

View File

@@ -920,7 +920,8 @@ Sets the item's font.
\func{bool}{SetItemImage}{\param{long }{item}, \param{int }{image}} \func{bool}{SetItemImage}{\param{long }{item}, \param{int }{image}}
Sets the image associated with the item. The image is an index into the Sets the image associated with the item. The image is an index into the
image list associated with the list control. image list associated with the list control. In report view, this only sets
the image for the first column.
\func{bool}{SetItemImage}{\param{long }{item}, \param{int }{image}, \param{int }{selImage}} \func{bool}{SetItemImage}{\param{long }{item}, \param{int }{image}, \param{int }{selImage}}
@@ -929,6 +930,14 @@ image list associated with the list control. This form is deprecated: {\it selIm
used. used.
\membersection{wxListCtrl::SetItemColumnImage}\label{wxlistctrlsetitemcolumnimage}
\func{bool}{SetItemImage}{\param{long }{item}, \param{long }{column}\param{int }{image}}
Sets the image associated with the item. In report view, you can specify the column.
The image is an index into the image list associated with the list control.
\membersection{wxListCtrl::SetItemPosition}\label{wxlistctrlsetitemposition} \membersection{wxListCtrl::SetItemPosition}\label{wxlistctrlsetitemposition}
\func{bool}{SetItemPosition}{\param{long }{item}, \param{const wxPoint\& }{pos}} \func{bool}{SetItemPosition}{\param{long }{item}, \param{const wxPoint\& }{pos}}

View File

@@ -100,6 +100,7 @@ public:
int GetItemState( long item, long stateMask ) const; int GetItemState( long item, long stateMask ) const;
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 );
wxString GetItemText( long item ) const; wxString GetItemText( long item ) 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;

View File

@@ -223,6 +223,7 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// Sets the item image // Sets the item image
bool SetItemImage(long item, int image, int selImage) ; bool SetItemImage(long item, int image, int selImage) ;
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) const ;

View File

@@ -223,6 +223,7 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// Sets the item image // Sets the item image
bool SetItemImage(long item, int image, int selImage) ; bool SetItemImage(long item, int image, int selImage) ;
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) const ;

View File

@@ -157,6 +157,7 @@ public:
// Sets the item image // Sets the item image
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);
// Gets the item text // Gets the item text
wxString GetItemText(long item) const ; wxString GetItemText(long item) const ;

View File

@@ -133,6 +133,10 @@ public:
,int nImage ,int nImage
,int lSelImage ,int lSelImage
); );
bool SetItemColumnImage( long lItem
,long lColumn
,int nImage
);
// //
// Item text // Item text

View File

@@ -154,6 +154,7 @@ public:
// Sets the item image // Sets the item image
bool SetItemImage(long item, int image, int selImage) ; bool SetItemImage(long item, int image, int selImage) ;
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) const ;

View File

@@ -491,6 +491,15 @@ void MyFrame::InitWithReportItems()
m_listCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE ); m_listCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
m_listCtrl->SetColumnWidth( 2, wxLIST_AUTOSIZE ); m_listCtrl->SetColumnWidth( 2, wxLIST_AUTOSIZE );
// Set images in columns
m_listCtrl->SetItemColumnImage(1, 1, 0);
wxListItem info;
info.SetImage(0);
info.SetId(3);
info.SetColumn(2);
m_listCtrl->SetItem(info);
// test SetItemFont too // test SetItemFont too
m_listCtrl->SetItemFont(0, *wxITALIC_FONT); m_listCtrl->SetItemFont(0, *wxITALIC_FONT);
} }
@@ -1012,9 +1021,15 @@ wxString MyListCtrl::OnGetItemText(long item, long column) const
} }
} }
int MyListCtrl::OnGetItemImage(long WXUNUSED(item)) const int MyListCtrl::OnGetItemColumnImage(long item, long column) const
{ {
return 0; if (!column)
return 0;
if (!(item %3) && column == 1)
return 0;
return -1;
} }
wxListItemAttr *MyListCtrl::OnGetItemAttr(long item) const wxListItemAttr *MyListCtrl::OnGetItemAttr(long item) const

View File

@@ -68,7 +68,7 @@ private:
void LogColEvent(const wxListEvent& event, const wxChar *eventName); void LogColEvent(const wxListEvent& event, const wxChar *eventName);
virtual wxString OnGetItemText(long item, long column) const; virtual wxString OnGetItemText(long item, long column) const;
virtual int OnGetItemImage(long item) const; virtual int OnGetItemColumnImage(long item, long column) const;
virtual wxListItemAttr *OnGetItemAttr(long item) const; virtual wxListItemAttr *OnGetItemAttr(long item) const;
wxListItemAttr m_attr; wxListItemAttr m_attr;

View File

@@ -4935,11 +4935,18 @@ bool wxGenericListCtrl::SetItemState( long item, long state, long stateMask )
bool bool
wxGenericListCtrl::SetItemImage( long item, int image, int WXUNUSED(selImage) ) wxGenericListCtrl::SetItemImage( long item, int image, int WXUNUSED(selImage) )
{
return SetItemColumnImage(item, 0, image);
}
bool
wxGenericListCtrl::SetItemColumnImage( long item, long column, int image )
{ {
wxListItem info; wxListItem info;
info.m_image = image; info.m_image = image;
info.m_mask = wxLIST_MASK_IMAGE; info.m_mask = wxLIST_MASK_IMAGE;
info.m_itemId = item; info.m_itemId = item;
info.m_col = column;
m_mainWin->SetItem( info ); m_mainWin->SetItem( info );
return true; return true;
} }

View File

@@ -918,12 +918,19 @@ bool wxListCtrl::SetItemState(long item, long state, long stateMask)
// Sets the item image // Sets the item image
bool wxListCtrl::SetItemImage(long item, int image, int WXUNUSED(selImage)) bool wxListCtrl::SetItemImage(long item, int image, int WXUNUSED(selImage))
{
return SetItemColumnImage(item, 0, image);
}
// Sets the item image
bool wxListCtrl::SetItemColumnImage(long item, long column, int image)
{ {
wxListItem info; wxListItem info;
info.m_mask = wxLIST_MASK_IMAGE; info.m_mask = wxLIST_MASK_IMAGE;
info.m_image = image; info.m_image = image;
info.m_itemId = item; info.m_itemId = item;
info.m_col = column;
return SetItem(info); return SetItem(info);
} }

View File

@@ -1543,14 +1543,24 @@ bool wxListCtrl::SetItemImage (
long lItem long lItem
, int nImage , int nImage
, int WXUNUSED(nSelImage)) , int WXUNUSED(nSelImage))
{
return SetItemColumnInfo(lItem, 0, nImage);
} // end of wxListCtrl::SetItemImage
// Sets the item image
bool wxListCtrl::SetItemColumnImage (
long lItem
, long lColumn
, int nImage
{ {
wxListItem vInfo; wxListItem vInfo;
vInfo.m_mask = wxLIST_MASK_IMAGE; vInfo.m_mask = wxLIST_MASK_IMAGE;
vInfo.m_image = nImage; vInfo.m_image = nImage;
vInfo.m_itemId = lItem; vInfo.m_itemId = lItem;
vInfo.m_col = lColumn;
return SetItem(vInfo); return SetItem(vInfo);
} // end of wxListCtrl::SetItemImage } // end of wxListCtrl::SetItemColumnImage
// Gets the item text // Gets the item text
wxString wxListCtrl::GetItemText ( wxString wxListCtrl::GetItemText (

View File

@@ -284,6 +284,12 @@ bool wxListCtrl::SetItemImage(long item, int image, int WXUNUSED(selImage))
return false; return false;
} }
// Sets the item image
bool wxListCtrl::SetItemColumnImage(long item, long column, int image)
{
return false;
}
// Gets the item text // Gets the item text
wxString wxListCtrl::GetItemText(long item) const wxString wxListCtrl::GetItemText(long item) const
{ {

View File

@@ -513,6 +513,7 @@ public:
// Sets the item image // Sets the item image
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 );
// Gets the item text // Gets the item text
wxString GetItemText(long item) const ; wxString GetItemText(long item) const ;