- Fix changing labels of menu items with bitmaps (Daniel Hyams).
- Fix appearance of multiline coloured wxCheckBox (Catalin Raceanu).
- Allow creating wxCursor from ANI files (Catalin Raceanu).
+- Add wxIcon::CreateFromHICON() (troelsk).
wxOSX/Cocoa:
wxBitmapType type = wxICON_DEFAULT_TYPE,
int desiredWidth = -1, int desiredHeight = -1);
+ bool CreateFromHICON(WXHICON icon);
+
// implementation only from now on
wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }
*/
virtual ~wxIcon();
+ /**
+ Attach a Windows icon handle.
+
+ This wxMSW-specific method allows to assign a native Windows @c HICON
+ (which must be castes to @c WXHICON opaque handle type) to wxIcon.
+ Notice that this means that the @c HICON will be destroyed by wxIcon
+ when it is destroyed.
+
+ @return @true if successful.
+
+ @onlyfor{wxmsw}
+
+ @since 2.9.5
+ */
+ bool CreateFromHICON(WXHICON icon);
+
/**
Returns disabled (dimmed) version of the icon.
{
icon->UnRef();
- // actual size
- wxSize size;
-
HICON hicon = NULL;
// Parse the filename: it may be of the form "filename;n" in order to
return false;
}
- size = wxGetHiconSize(hicon);
+ if ( !icon->CreateFromHICON(hicon) )
+ return false;
- if ( (desiredWidth != -1 && desiredWidth != size.x) ||
- (desiredHeight != -1 && desiredHeight != size.y) )
+ if ( (desiredWidth != -1 && desiredWidth != icon->GetWidth()) ||
+ (desiredHeight != -1 && desiredHeight != icon->GetHeight()) )
{
wxLogTrace(wxT("iconload"),
wxT("Returning false from wxICOFileHandler::Load because of the size mismatch: actual (%d, %d), requested (%d, %d)"),
- size.x, size.y,
+ icon->GetWidth(), icon->GetHeight(),
desiredWidth, desiredHeight);
- ::DestroyIcon(hicon);
+ icon->UnRef();
return false;
}
- icon->SetHICON((WXHICON)hicon);
- icon->SetSize(size.x, size.y);
-
- return icon->IsOk();
+ return true;
}
bool wxICOResourceHandler::LoadIcon(wxIcon *icon,
}
#endif
- wxSize size = wxGetHiconSize(hicon);
- icon->SetSize(size.x, size.y);
-
- icon->SetHICON((WXHICON)hicon);
-
- return icon->IsOk();
+ return icon->CreateFromHICON((WXHICON)hicon);
}
#if wxUSE_PNG_RESOURCE_HANDLER
return handler->Load(this, filename, type, desiredWidth, desiredHeight);
}
+
+bool wxIcon::CreateFromHICON(WXHICON icon)
+{
+ SetHICON(icon);
+ if ( !IsOk() )
+ return false;
+
+ SetSize(wxGetHiconSize(icon));
+
+ return true;
+}