Skip to content

State images for wxTreeCtrl not updating for DPI changes when no images are set #26059

@HenkDemper

Description

@HenkDemper

Hi Vadim, others.

Using wxWidgets f3aa944 from git on Mac Tahoe 26.2

  • I'm using wxTreeCtrl with only State Images by wxTreeCtrl::SetStateImages() with a wxVector<wxBitmapBundle> with 16x16 (in red) and 32x32 (in green for test) wxBitmaps
  • I set states with wxTreeCtrl::SetItemState() for each Child Item (for test)
  • I start the application on a HDPI display and it will use the 32x32 Bitmaps (1st image with 32x32 green state images)
Image
  • I then drag the application to a non-HDPI display and it will still use the 32x32 Bitmaps, which are now too big (2nd image with large 32x32 green state images)
Image
  • In debugger with wxWidgets source I think I traced it down to the wxWithImages function:

void WXHandleDPIChanged(wxDPIChangedEvent& event)
{
if ( HasImages() )
OnImagesChanged();
event.Skip();
}

  • Because I only set State Images, HasImages() returns false and hence virtual wxGenericTreeCtrl::OnImagesChanged() is never called, which should handle DPI changes for the state images by m_imagesState.GetUpdatedImageListFor(this)
  • If during initialisation apart from wxTreeCtrl::SetStateImages(BitmapBundleList) I also call wxTreeCtrl::SetImages(BitmapBundleList) (even though I don't use any Item Images), then the State Images will become DPI-aware correctly as expected (3rd images with 16x16 red state images)
    wxGenericTreeCtrl::OnImagesChanged() will be used to handle DPI changes for State Images
Image
  • So there is a workaround, but it might be worthwhile fixing ? (although it might be difficult in wxWithImages to judge that wxTreeCtrl will use OnImagesChanged() to update it State Images... ?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions