Merge wxListCtrl fixes for classic MSW there
Closes https://github.com/wxWidgets/wxWidgets/pull/216
This commit is contained in:
@@ -230,6 +230,19 @@ int wxImageList::Add(const wxBitmap& bitmap, const wxColour& maskColour)
|
|||||||
// Adds a bitmap and mask from an icon.
|
// Adds a bitmap and mask from an icon.
|
||||||
int wxImageList::Add(const wxIcon& icon)
|
int wxImageList::Add(const wxIcon& icon)
|
||||||
{
|
{
|
||||||
|
// ComCtl32 prior 6.0 doesn't support images with alpha
|
||||||
|
// channel so if we have 32-bit icon with transparency
|
||||||
|
// we need to add it as a wxBitmap via dedicated method
|
||||||
|
// where alpha channel will be converted to the mask.
|
||||||
|
if ( wxApp::GetComCtl32Version() < 600 )
|
||||||
|
{
|
||||||
|
wxBitmap bmp(icon);
|
||||||
|
if ( bmp.HasAlpha() )
|
||||||
|
{
|
||||||
|
return Add(bmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int index = ImageList_AddIcon(GetHImageList(), GetHiconOf(icon));
|
int index = ImageList_AddIcon(GetHImageList(), GetHiconOf(icon));
|
||||||
if ( index == -1 )
|
if ( index == -1 )
|
||||||
{
|
{
|
||||||
@@ -292,6 +305,19 @@ bool wxImageList::Replace(int index,
|
|||||||
// Replaces a bitmap and mask from an icon.
|
// Replaces a bitmap and mask from an icon.
|
||||||
bool wxImageList::Replace(int i, const wxIcon& icon)
|
bool wxImageList::Replace(int i, const wxIcon& icon)
|
||||||
{
|
{
|
||||||
|
// ComCtl32 prior 6.0 doesn't support images with alpha
|
||||||
|
// channel so if we have 32-bit icon with transparency
|
||||||
|
// we need to replace it as a wxBitmap via dedicated method
|
||||||
|
// where alpha channel will be converted to the mask.
|
||||||
|
if ( wxApp::GetComCtl32Version() < 600 )
|
||||||
|
{
|
||||||
|
wxBitmap bmp(icon);
|
||||||
|
if ( bmp.HasAlpha() )
|
||||||
|
{
|
||||||
|
return Replace(i, bmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ok = ImageList_ReplaceIcon(GetHImageList(), i, GetHiconOf(icon)) != -1;
|
bool ok = ImageList_ReplaceIcon(GetHImageList(), i, GetHiconOf(icon)) != -1;
|
||||||
if ( !ok )
|
if ( !ok )
|
||||||
{
|
{
|
||||||
|
@@ -1341,6 +1341,18 @@ void wxListCtrl::SetImageList(wxImageList *imageList, int which)
|
|||||||
m_ownsImageListState = false;
|
m_ownsImageListState = false;
|
||||||
}
|
}
|
||||||
(void) ListView_SetImageList(GetHwnd(), (HIMAGELIST) imageList ? imageList->GetHIMAGELIST() : 0, flags);
|
(void) ListView_SetImageList(GetHwnd(), (HIMAGELIST) imageList ? imageList->GetHIMAGELIST() : 0, flags);
|
||||||
|
|
||||||
|
// For ComCtl32 prior 6.0 we need to re-assign all existing
|
||||||
|
// text labels in order to position them correctly.
|
||||||
|
if ( wxApp::GetComCtl32Version() < 600 )
|
||||||
|
{
|
||||||
|
const int n = GetItemCount();
|
||||||
|
for( int i = 0; i < n; i++ )
|
||||||
|
{
|
||||||
|
wxString text = GetItemText(i);
|
||||||
|
SetItemText(i, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListCtrl::AssignImageList(wxImageList *imageList, int which)
|
void wxListCtrl::AssignImageList(wxImageList *imageList, int which)
|
||||||
|
Reference in New Issue
Block a user