X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3a5bcc4db0851bf8cd3063917511b0b17c7f9679..966b84b9140622dd94b081206bb52ceb5ce2c401:/src/generic/imaglist.cpp?ds=sidebyside diff --git a/src/generic/imaglist.cpp b/src/generic/imaglist.cpp index ea69fbfaf2..3e3f71cd46 100644 --- a/src/generic/imaglist.cpp +++ b/src/generic/imaglist.cpp @@ -14,11 +14,18 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_IMAGLIST + #ifdef __BORLANDC__ #pragma hdrstop #endif +#include "wx/defs.h" + +#ifndef __WXPALMOS__ + #include "wx/generic/imaglist.h" + #include "wx/icon.h" #include "wx/image.h" #include "wx/dc.h" @@ -63,13 +70,13 @@ bool wxGenericImageList::Create( int width, int height, bool WXUNUSED(mask), int bool wxGenericImageList::Create() { - return TRUE; + return true; } int wxGenericImageList::Add( const wxBitmap &bitmap ) { - wxASSERT_MSG( bitmap.GetWidth() == m_width && - bitmap.GetHeight() == m_height, + wxASSERT_MSG( (bitmap.GetWidth() == m_width && bitmap.GetHeight() == m_height) + || (m_width == 0 && m_height == 0), _T("invalid bitmap size in wxImageList: this might work ") _T("on this platform but definitely won't under Windows.") ); @@ -77,6 +84,13 @@ int wxGenericImageList::Add( const wxBitmap &bitmap ) m_images.Append( new wxIcon( (const wxIcon&) bitmap ) ); else m_images.Append( new wxBitmap(bitmap) ); + + if (m_width == 0 && m_height == 0) + { + m_width = bitmap.GetWidth(); + m_height = bitmap.GetHeight(); + } + return m_images.GetCount()-1; } @@ -95,7 +109,7 @@ int wxGenericImageList::Add( const wxBitmap& bitmap, const wxColour& maskColour return Add(wxBitmap(img)); } -const wxBitmap *wxGenericImageList::GetBitmap( int index ) const +const wxBitmap *wxGenericImageList::GetBitmapPtr( int index ) const { wxList::compatibility_iterator node = m_images.Item( index ); @@ -104,11 +118,35 @@ const wxBitmap *wxGenericImageList::GetBitmap( int index ) const return (wxBitmap*)node->GetData(); } +// Get the bitmap +wxBitmap wxGenericImageList::GetBitmap(int index) const +{ + const wxBitmap* bmp = GetBitmapPtr(index); + if (bmp) + return *bmp; + else + return wxNullBitmap; +} + +// Get the icon +wxIcon wxGenericImageList::GetIcon(int index) const +{ + const wxBitmap* bmp = GetBitmapPtr(index); + if (bmp) + { + wxIcon icon; + icon.CopyFromBitmap(*bmp); + return icon; + } + else + return wxNullIcon; +} + bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap ) { wxList::compatibility_iterator node = m_images.Item( index ); - wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); + wxCHECK_MSG( node, false, wxT("wrong index in image list") ); wxBitmap* newBitmap = (bitmap.IsKindOf(CLASSINFO(wxIcon))) ? #if defined(__VISAGECPP__) @@ -134,19 +172,19 @@ bool wxGenericImageList::Replace( int index, const wxBitmap &bitmap ) m_images.Insert( next, newBitmap ); } - return TRUE; + return true; } bool wxGenericImageList::Remove( int index ) { wxList::compatibility_iterator node = m_images.Item( index ); - wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); + wxCHECK_MSG( node, false, wxT("wrong index in image list") ); delete node->GetData(); m_images.Erase( node ); - return TRUE; + return true; } bool wxGenericImageList::RemoveAll() @@ -154,7 +192,7 @@ bool wxGenericImageList::RemoveAll() WX_CLEAR_LIST(wxList, m_images); m_images.Clear(); - return TRUE; + return true; } bool wxGenericImageList::GetSize( int index, int &width, int &height ) const @@ -164,13 +202,13 @@ bool wxGenericImageList::GetSize( int index, int &width, int &height ) const wxList::compatibility_iterator node = m_images.Item( index ); - wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); + wxCHECK_MSG( node, false, wxT("wrong index in image list") ); wxBitmap *bm = (wxBitmap*)node->GetData(); width = bm->GetWidth(); height = bm->GetHeight(); - return TRUE; + return true; } bool wxGenericImageList::Draw( int index, wxDC &dc, int x, int y, @@ -178,7 +216,7 @@ bool wxGenericImageList::Draw( int index, wxDC &dc, int x, int y, { wxList::compatibility_iterator node = m_images.Item( index ); - wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") ); + wxCHECK_MSG( node, false, wxT("wrong index in image list") ); wxBitmap *bm = (wxBitmap*)node->GetData(); @@ -187,7 +225,8 @@ bool wxGenericImageList::Draw( int index, wxDC &dc, int x, int y, else dc.DrawBitmap( *bm, x, y, (flags & wxIMAGELIST_DRAW_TRANSPARENT) > 0 ); - return TRUE; + return true; } - +#endif // wxUSE_IMAGLIST +#endif // __WXPALMOS__