X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/20b6985553b4e01e7960847e3211d940aeff8742..914955aaa034862c3b9b827463cde26455d06c79:/src/mac/carbon/icon.cpp diff --git a/src/mac/carbon/icon.cpp b/src/mac/carbon/icon.cpp index 914b40b46b..a3bd7817c1 100644 --- a/src/mac/carbon/icon.cpp +++ b/src/mac/carbon/icon.cpp @@ -24,6 +24,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) #include "wx/image.h" #include "wx/mac/private.h" +#define M_ICONDATA ((wxIconRefData *)m_refData) + /* * Icons @@ -69,12 +71,32 @@ WXHICON wxIcon::GetHICON() const int wxIcon::GetWidth() const { - return 32 ; + wxCHECK_MSG( Ok(), -1, wxT("invalid icon") ); + + return M_ICONDATA->GetWidth(); } int wxIcon::GetHeight() const { - return 32 ; + wxCHECK_MSG( Ok(), -1, wxT("invalid icon") ); + + return M_ICONDATA->GetHeight(); +} + +int wxIcon::GetDepth() const{ + return 32; +} + +void wxIcon::SetDepth(int depth){ + +} + +void wxIcon::SetWidth(int width){ + +} + +void wxIcon::SetHeight(int height){ + } bool wxIcon::Ok() const @@ -148,6 +170,7 @@ bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type, } else { +#if wxUSE_IMAGE wxImage loadimage(filename, type); if (loadimage.Ok()) { @@ -161,6 +184,7 @@ bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type, CopyFromBitmap( bmp ) ; return true; } +#endif } } return true ; @@ -170,12 +194,20 @@ void wxIcon::CopyFromBitmap(const wxBitmap& bmp) { UnRef() ; - m_refData = new wxIconRefData( (WXHICON) wxMacCreateIconRef( bmp ) ) ; + // as the bitmap owns that ref, we have to acquire it as well + IconRef iconRef = bmp.GetBitmapData()->GetIconRef() ; + AcquireIconRef( iconRef ) ; + m_refData = new wxIconRefData( (WXHICON) iconRef ) ; + M_ICONDATA->SetWidth( bmp.GetWidth() ) ; + M_ICONDATA->SetHeight( bmp.GetHeight() ) ; } wxIconRefData::wxIconRefData( WXHICON icon ) { m_iconRef = MAC_WXHICON( icon ) ; + // Std sizes + SetWidth( 32 ) ; + SetHeight( 32 ) ; } void wxIconRefData::Init()