/////////////////////////////////////////////////////////////////////////////
-// Name: generic/imaglist.cpp
+// Name: src/generic/imaglist.cpp
// Purpose:
// Author: Robert Roebling
// Id: $id$
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef __PALMOS__
-
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "imaglist.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
+#if wxUSE_IMAGLIST
+
+#ifndef __WXPALMOS__
+
#include "wx/generic/imaglist.h"
+
#include "wx/icon.h"
#include "wx/image.h"
#include "wx/dc.h"
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.") );
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;
}
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 );
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 );
return true;
}
-#endif // __PALMOS__
+#endif // wxUSE_IMAGLIST
+#endif // __WXPALMOS__