adjust spacing and calculate layout correctly for icons larger than 32x32

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7270 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-04-25 07:03:41 +00:00
parent 9d98a27ad6
commit 041bc561e8

View File

@@ -644,6 +644,11 @@ void wxListLineData::CalculateSize( wxDC *dc, int spacing )
m_owner->GetImageSize( item->GetImage(), w, h ); m_owner->GetImageSize( item->GetImage(), w, h );
m_bound_icon.width = w + 8; m_bound_icon.width = w + 8;
m_bound_icon.height = h + 8; m_bound_icon.height = h + 8;
if ( m_bound_icon.width > m_bound_all.width )
m_bound_all.width = m_bound_icon.width;
if ( h + lh > m_bound_all.height - 4 )
m_bound_all.height = h + lh + 4;
} }
if (!item->HasText()) if (!item->HasText())
@@ -737,7 +742,8 @@ void wxListLineData::SetPosition( wxDC * WXUNUSED(dc),
wxListItemData *item = (wxListItemData*)node->Data(); wxListItemData *item = (wxListItemData*)node->Data();
if (item->HasImage()) if (item->HasImage())
{ {
m_bound_icon.x = m_bound_all.x + 4 + (m_spacing/2) - (m_bound_icon.width/2); m_bound_icon.x = m_bound_all.x + 4
+ (m_spacing - m_bound_icon.width)/2;
m_bound_icon.y = m_bound_all.y + 4; m_bound_icon.y = m_bound_all.y + 4;
} }
if (item->HasText()) if (item->HasText())
@@ -2232,8 +2238,26 @@ int wxListMainWindow::GetIndexOfLine( const wxListLineData *line )
void wxListMainWindow::SetImageList( wxImageList *imageList, int which ) void wxListMainWindow::SetImageList( wxImageList *imageList, int which )
{ {
m_dirty = TRUE; m_dirty = TRUE;
if (which == wxIMAGE_LIST_NORMAL) m_normal_image_list = imageList;
if (which == wxIMAGE_LIST_SMALL) m_small_image_list = imageList; // calc the spacing from the icon size
int width = 0,
height = 0;
if ( imageList->GetImageCount() )
{
imageList->GetSize(0, width, height);
}
if (which == wxIMAGE_LIST_NORMAL)
{
m_normal_image_list = imageList;
m_normal_spacing = width + 8;
}
if (which == wxIMAGE_LIST_SMALL)
{
m_small_image_list = imageList;
m_small_spacing = width + 14;
}
} }
void wxListMainWindow::SetItemSpacing( int spacing, bool isSmall ) void wxListMainWindow::SetItemSpacing( int spacing, bool isSmall )
@@ -2251,7 +2275,7 @@ void wxListMainWindow::SetItemSpacing( int spacing, bool isSmall )
int wxListMainWindow::GetItemSpacing( bool isSmall ) int wxListMainWindow::GetItemSpacing( bool isSmall )
{ {
if (isSmall) return m_small_spacing; else return m_normal_spacing; return isSmall ? m_small_spacing : m_normal_spacing;
} }
void wxListMainWindow::SetColumn( int col, wxListItem &item ) void wxListMainWindow::SetColumn( int col, wxListItem &item )