[Git][wxwidgets/wxwidgets][master] 3 commits: Add system color change event handler to wxDataViewCtrl

2 views
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
May 2, 2026, 5:33:29 PMMay 2
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • 5f75241f
    by Steve Cornett at 2026-05-02T22:55:17+02:00
    Add system color change event handler to wxDataViewCtrl
    
    Make the control update its appearance after system theme change under
    Windows.
    
    Closes #26420.
    
  • b45b02c2
    by Vadim Zeitlin at 2026-05-02T23:21:52+02:00
    Fix loading of standard icons recently broken in wxMSW
    
    The changes of 96eaa04e9bc (Stop scaling icons loaded from resources in
    wxMSW, 2026-04-10) broke loading standard icons because they must be
    loaded with LR_SHARED flag and LoadImage() simply fails to load them
    without it.
    
    But there is no point in using LoadImage() for the standard icons anyhow
    as it behaves in exactly the same way as LoadIcon(), so just restore the
    code from before the commit above, including setting the scale factor
    for the standard icons.
    
    Still preserve the change of that commit for the application-defined
    icons, which is what counts.
    
    See #26369, #26370.
    
  • f57b17ba
    by Vadim Zeitlin at 2026-05-02T23:21:53+02:00
    Allow decreasing AUI pane sizes below their initial size again
    
    This change basically reverts 7d87a3fc6c1 (Don't forcible reset item min
    size to (1,1) in wxAUI, 2025-11-30) except that it simplifies the code a
    little by calling wxSizerItem::SetMinSize() just once instead of doing
    it twice, with the second call overwriting the value set by the first
    one.
    
    This allows AUI panes to become smaller than their initial size, which
    is compatible with the behaviour of the previous (pre-3.3.2) wx versions
    even if it is less compatible with the behaviour of non-AUI windows,
    which use their initial size as their min size too, unlike AUI panes for
    which wxAuiPaneInfo::MinSize() must be explicitly used to set the min
    size.
    
    Closes #26302.
    

4 changed files:

Changes:

  • include/wx/generic/dataview.h
    ... ... @@ -362,6 +362,8 @@ public: // utility functions not part of the API
    362 362
     
    
    363 363
         virtual void OnInternalIdle() override;
    
    364 364
     
    
    365
    +    void OnSysColourChanged(wxSysColourChangedEvent& event);
    
    366
    +
    
    365 367
     #if wxUSE_ACCESSIBILITY
    
    366 368
         virtual wxAccessible* CreateAccessible() override;
    
    367 369
     #endif // wxUSE_ACCESSIBILITY
    

  • src/aui/framemanager.cpp
    ... ... @@ -2457,10 +2457,13 @@ void wxAuiManager::LayoutAddPane(wxSizer* cont,
    2457 2457
             }
    
    2458 2458
         }
    
    2459 2459
     
    
    2460
    -    if (min_size != wxDefaultSize)
    
    2461
    -    {
    
    2462
    -        sizer_item->SetMinSize(min_size);
    
    2463
    -    }
    
    2460
    +    // We need to reset any previous set min size to allow decreasing the pane
    
    2461
    +    // size by dragging the sash between it and other panes, so always set it
    
    2462
    +    // to something, even if it's not specified.
    
    2463
    +    if (min_size == wxDefaultSize)
    
    2464
    +        min_size = wxSize(1, 1);
    
    2465
    +
    
    2466
    +    sizer_item->SetMinSize(min_size);
    
    2464 2467
     
    
    2465 2468
     
    
    2466 2469
         // add the vertical sizer (caption, pane window) to the
    

  • src/generic/datavgen.cpp
    ... ... @@ -5683,6 +5683,8 @@ bool wxDataViewCtrl::Create(wxWindow *parent,
    5683 5683
     
    
    5684 5684
         EnableSystemThemeByDefault();
    
    5685 5685
     
    
    5686
    +    Bind(wxEVT_SYS_COLOUR_CHANGED, &wxDataViewCtrl::OnSysColourChanged, this);
    
    5687
    +
    
    5686 5688
     #if wxUSE_ACCESSIBILITY
    
    5687 5689
         wxAccessible::NotifyEvent(wxACC_EVENT_OBJECT_CREATE, this, wxOBJID_CLIENT, wxACC_SELF);
    
    5688 5690
     #endif // wxUSE_ACCESSIBILITY
    
    ... ... @@ -6266,6 +6268,12 @@ void wxDataViewCtrl::OnInternalIdle()
    6266 6268
             UpdateColWidths();
    
    6267 6269
     }
    
    6268 6270
     
    
    6271
    +void wxDataViewCtrl::OnSysColourChanged(wxSysColourChangedEvent& event)
    
    6272
    +{
    
    6273
    +    Refresh();
    
    6274
    +    event.Skip();
    
    6275
    +}
    
    6276
    +
    
    6269 6277
     int wxDataViewCtrl::GetColumnPosition( const wxDataViewColumn *column ) const
    
    6270 6278
     {
    
    6271 6279
         unsigned int len = GetColumnCount();
    

  • src/msw/gdiimage.cpp
    ... ... @@ -618,6 +618,8 @@ bool wxICOResourceHandler::LoadIcon(wxIcon *icon,
    618 618
             desiredHeight = 0;
    
    619 619
         }
    
    620 620
     
    
    621
    +    bool iconMayBeScaled = false;
    
    622
    +
    
    621 623
         // try to load the icon from this program first to allow overriding the
    
    622 624
         // standard icons (although why one would want to do it considering that
    
    623 625
         // we already have wxApp::GetStdIcon() is unclear)
    
    ... ... @@ -635,13 +637,15 @@ bool wxICOResourceHandler::LoadIcon(wxIcon *icon,
    635 637
             else // We may still succeed in loading the standard icon.
    
    636 638
             {
    
    637 639
                 const auto& entry = stdIcons[nStdIcon];
    
    638
    -            hicon = (HICON)::LoadImage((HINSTANCE)nullptr, entry.id, IMAGE_ICON,
    
    639
    -                                       desiredWidth, desiredHeight,
    
    640
    -                                       LR_DEFAULTSIZE | LR_DEFAULTCOLOR);
    
    640
    +            hicon = ::LoadIcon((HINSTANCE)nullptr, entry.id);
    
    641 641
                 if ( !hicon )
    
    642 642
                 {
    
    643
    -                wxLogLastError(wxString::Format("LoadImage(%s)", entry.name));
    
    643
    +                wxLogLastError(wxString::Format("LoadIcon(%s)", entry.name));
    
    644 644
                 }
    
    645
    +
    
    646
    +            // LoadIcon() may scale the icon in high DPI, so get its actual
    
    647
    +            // size below.
    
    648
    +            iconMayBeScaled = true;
    
    645 649
             }
    
    646 650
         }
    
    647 651
     
    
    ... ... @@ -649,17 +653,22 @@ bool wxICOResourceHandler::LoadIcon(wxIcon *icon,
    649 653
             return false;
    
    650 654
     
    
    651 655
         wxSize size;
    
    656
    +    double scale = 1.0;
    
    652 657
         if ( hasSize )
    
    653 658
         {
    
    654 659
             size.x = desiredWidth;
    
    655 660
             size.y = desiredHeight;
    
    656 661
         }
    
    657
    -    else
    
    662
    +    else if ( iconMayBeScaled )
    
    658 663
         {
    
    664
    +        // LoadIcon() returns icons of scaled size, so we must use the correct
    
    665
    +        // scaling factor of them.
    
    659 666
             size = wxGetHiconSize(hicon);
    
    667
    +        if ( const wxWindow* win = wxApp::GetMainTopWindow() )
    
    668
    +            scale = win->GetDPIScaleFactor();
    
    660 669
         }
    
    661 670
     
    
    662
    -    return icon->InitFromHICON((WXHICON)hicon, size.x, size.y);
    
    671
    +    return icon->InitFromHICON((WXHICON)hicon, size.x, size.y, scale);
    
    663 672
     }
    
    664 673
     
    
    665 674
     #if wxUSE_PNG_RESOURCE_HANDLER
    

Reply all
Reply to author
Forward
0 new messages