[Git][wxwidgets/wxwidgets][master] 9 commits: Some small fixes for wxAboutBox HiDPI support

2 views
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
May 21, 2026, 8:31:00 PMMay 21
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • 47c35e67
    by Paul Cornett at 2026-05-21T15:17:38-07:00
    Some small fixes for wxAboutBox HiDPI support
    
    Always use the wxApp top window for default icon bundle, it's possible the
    provided window is not the main one. Pass window argument to GetIcon() in
    generic implementation. Make GetIcon() window parameter pointer-to-const.
    
  • 60d63f52
    by Paul Cornett at 2026-05-21T15:19:26-07:00
    Use wxFALLTHROUGH annotation
    
  • b2fd4607
    by Paul Cornett at 2026-05-21T15:22:38-07:00
    Remove redundant bitmap IsOk() check
    
    Bitmap is always valid at that point
    
  • 091e339b
    by Paul Cornett at 2026-05-21T15:27:38-07:00
    Fix handling of GTK wxSearchCtrl GetSizeFromTextSize() ylen parameter
    
    It's supposed to be the height of the area for text
    
  • 27a8c83a
    by Paul Cornett at 2026-05-21T15:40:58-07:00
    Avoid -Wunreachable-code-break warning
    
  • 55253b59
    by Paul Cornett at 2026-05-21T15:55:06-07:00
    Remove redundant SetInitialSize()
    
    PostCreation() already did that
    
  • 704fc166
    by Paul Cornett at 2026-05-21T16:35:50-07:00
    Set label after attaching to parent during creation
    
    This makes it more likely initial size will be correct
    
  • 945e7f70
    by Paul Cornett at 2026-05-21T16:56:54-07:00
    Avoid Gtk-CRITICAL warning during tests resulting from use of wxAuiMDIChildFrame
    
    wxAuiMDIChildFrame is not really a TLW. Ugh.
    
  • 8e005d1c
    by Paul Cornett at 2026-05-21T16:57:51-07:00
    Remove m_ prefix from local variable
    

12 changed files:

Changes:

  • include/wx/aboutdlg.h
    ... ... @@ -70,7 +70,7 @@ public:
    70 70
         // icon to be shown in the dialog, defaults to the main frame icon
    
    71 71
         void SetIcon(const wxBitmapBundle& icon) { m_icon = icon; }
    
    72 72
         bool HasIcon() const { return m_icon.IsOk(); }
    
    73
    -    wxIcon GetIcon(wxWindow* window = nullptr) const;
    
    73
    +    wxIcon GetIcon(const wxWindow* window = nullptr) const;
    
    74 74
     
    
    75 75
         // web site for the program and its description (defaults to URL itself if
    
    76 76
         // empty)
    

  • interface/wx/aboutdlg.h
    ... ... @@ -184,7 +184,7 @@ public:
    184 184
                If non-null, this is used to help select an icon based on window DPI.
    
    185 185
                New since wxWidgets 3.3.3.
    
    186 186
         */
    
    187
    -    wxIcon GetIcon(wxWindow* window = nullptr) const;
    
    187
    +    wxIcon GetIcon(const wxWindow* window = nullptr) const;
    
    188 188
     
    
    189 189
         /**
    
    190 190
             Set the icon to be shown in the dialog. By default the icon of the main frame
    

  • src/common/numformatter.cpp
    ... ... @@ -354,6 +354,7 @@ wxString wxNumberFormatter::RemoveCurrencySymbolOrCode(wxString s, int style)
    354 354
                 case wxCurrencySymbolPosition::PrefixWithSep:
    
    355 355
                     currencyStr += wxString(" ");
    
    356 356
                     // Fall through to case without separator
    
    357
    +                wxFALLTHROUGH;
    
    357 358
                 case wxCurrencySymbolPosition::PrefixNoSep:
    
    358 359
                     if (s.StartsWith(currencyStr, &valueStr))
    
    359 360
                         s = valueStr;
    
    ... ... @@ -361,6 +362,7 @@ wxString wxNumberFormatter::RemoveCurrencySymbolOrCode(wxString s, int style)
    361 362
                 case wxCurrencySymbolPosition::SuffixWithSep:
    
    362 363
                     currencyStr = wxString(" ") + currencyStr;
    
    363 364
                     // Fall through to case without separator
    
    365
    +                wxFALLTHROUGH;
    
    364 366
                 case wxCurrencySymbolPosition::SuffixNoSep:
    
    365 367
                     if (s.EndsWith(currencyStr, &valueStr))
    
    366 368
                         s = valueStr;
    

  • src/generic/aboutdlgg.cpp
    ... ... @@ -80,18 +80,22 @@ wxString wxAboutDialogInfo::GetDescriptionAndCredits() const
    80 80
         return s;
    
    81 81
     }
    
    82 82
     
    
    83
    -wxIcon wxAboutDialogInfo::GetIcon(wxWindow* window) const
    
    83
    +wxIcon wxAboutDialogInfo::GetIcon(const wxWindow* window) const
    
    84 84
     {
    
    85
    -    if (window == nullptr)
    
    86
    -        window = wxApp::GetMainTopWindow();
    
    87 85
         wxBitmapBundle bundle(m_icon);
    
    88 86
         if ( !bundle.IsOk() )
    
    89 87
         {
    
    90 88
             const wxTopLevelWindow * const
    
    91
    -            tlw = wxDynamicCast(wxGetTopLevelParent(window), wxTopLevelWindow);
    
    89
    +            tlw = wxDynamicCast(wxApp::GetMainTopWindow(), wxTopLevelWindow);
    
    92 90
             if ( tlw )
    
    91
    +        {
    
    93 92
                 bundle = wxBitmapBundle::FromIconBundle(tlw->GetIcons());
    
    93
    +            if (window == nullptr)
    
    94
    +                window = tlw;
    
    95
    +        }
    
    94 96
         }
    
    97
    +    else if (window == nullptr)
    
    98
    +        window = wxApp::GetMainTopWindow();
    
    95 99
     
    
    96 100
         wxIcon icon;
    
    97 101
         if (bundle.IsOk())
    
    ... ... @@ -229,7 +233,7 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* paren
    229 233
         sizerIconAndText->AddSpacer(horzBorder);
    
    230 234
     
    
    231 235
     #if wxUSE_STATBMP
    
    232
    -    wxIcon icon = info.GetIcon();
    
    236
    +    wxIcon icon = info.GetIcon(parent);
    
    233 237
         if ( icon.IsOk() )
    
    234 238
         {
    
    235 239
             sizerIconAndText->Add(new wxStaticBitmap(m_contents, wxID_ANY, icon),
    

  • src/gtk/filepicker.cpp
    ... ... @@ -126,7 +126,6 @@ bool wxFileButton::Create( wxWindow *parent, wxWindowID id,
    126 126
             m_parent->DoAddChild( this );
    
    127 127
     
    
    128 128
             PostCreation(size);
    
    129
    -        SetInitialSize(size);
    
    130 129
         }
    
    131 130
         else // Use generic implementation.
    
    132 131
         {
    

  • src/gtk/image_gtk.cpp
    ... ... @@ -148,8 +148,7 @@ static gboolean wxGtkImageDraw(GtkWidget* widget, GdkEventExpose* event)
    148 148
     #ifdef __WXGTK3__
    
    149 149
         gtk_render_background(gtk_widget_get_style_context(widget),
    
    150 150
             cr, 0, 0, alloc.width, alloc.height);
    
    151
    -    if (bitmap.IsOk())
    
    152
    -        bitmap.Draw(cr, x, y);
    
    151
    +    bitmap.Draw(cr, x, y);
    
    153 152
     #else
    
    154 153
         x += alloc.x;
    
    155 154
         y += alloc.y;
    

  • src/gtk/radiobox.cpp
    ... ... @@ -255,7 +255,6 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
    255 255
     
    
    256 256
         m_widget = GTKCreateFrame(title);
    
    257 257
         g_object_ref(m_widget);
    
    258
    -    wxControl::SetLabel(title);
    
    259 258
         if ( HasFlag(wxNO_BORDER) )
    
    260 259
         {
    
    261 260
             // If we don't do this here, the wxNO_BORDER style is ignored in Show()
    
    ... ... @@ -395,6 +394,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
    395 394
     
    
    396 395
         m_parent->DoAddChild( this );
    
    397 396
     
    
    397
    +    wxControl::SetLabel(title);
    
    398 398
         PostCreation(size);
    
    399 399
     
    
    400 400
         return true;
    

  • src/gtk/srchctrl.cpp
    ... ... @@ -394,8 +394,8 @@ wxSize wxSearchCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const
    394 394
     {
    
    395 395
         wxSize size(GTKGetPreferredSize(m_widget));
    
    396 396
         size.x += xlen;
    
    397
    -    if (size.y < ylen)
    
    398
    -        size.y = ylen;
    
    397
    +    if (ylen > 0)
    
    398
    +        size.y += ylen - GetCharHeight();
    
    399 399
     
    
    400 400
     #ifdef wxHAS_GTK_SEARCH_ENTRY
    
    401 401
         if (HasGtkSearchEntry() &&
    

  • src/gtk/stattext.cpp
    ... ... @@ -125,10 +125,10 @@ bool wxStaticText::Create(wxWindow *parent,
    125 125
     
    
    126 126
         gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE );
    
    127 127
     
    
    128
    -    SetLabel(label);
    
    129
    -
    
    130 128
         m_parent->DoAddChild( this );
    
    131 129
     
    
    130
    +    SetLabel(label);
    
    131
    +
    
    132 132
         PostCreation(size);
    
    133 133
     
    
    134 134
     #ifndef __WXGTK3__
    

  • src/gtk/toplevel.cpp
    ... ... @@ -402,6 +402,12 @@ void wxTopLevelWindowGTK::GTKHandleRealized()
    402 402
     
    
    403 403
         wxNonOwnedWindow::GTKHandleRealized();
    
    404 404
     
    
    405
    +    if (!GTK_IS_WINDOW(m_widget))
    
    406
    +    {
    
    407
    +        // This is some kind of not-a-TLW
    
    408
    +        return;
    
    409
    +    }
    
    410
    +
    
    405 411
         GdkWindow* window = gtk_widget_get_window(m_widget);
    
    406 412
     
    
    407 413
     #if GTK_CHECK_VERSION(3,10,0)
    

  • src/osx/carbon/graphics.cpp
    ... ... @@ -91,7 +91,6 @@ bool wxOSXGetCGBlendMode(wxCompositionMode op, wxInt32& mode)
    91 91
                 break;
    
    92 92
             default:
    
    93 93
                 return false;
    
    94
    -            break;
    
    95 94
         }
    
    96 95
         return true;
    
    97 96
     }
    

  • tests/controls/spinctrldbltest.cpp
    ... ... @@ -56,12 +56,12 @@ TEST_CASE("SpinCtrlDouble::NoEventsInCtor", "[spinctrl][spinctrldouble]")
    56 56
     {
    
    57 57
         // Verify that creating the control does not generate any events. This is
    
    58 58
         // unexpected and shouldn't happen.
    
    59
    -    std::unique_ptr<wxSpinCtrlDouble> m_spin(new wxSpinCtrlDouble);
    
    59
    +    std::unique_ptr<wxSpinCtrlDouble> spin(new wxSpinCtrlDouble);
    
    60 60
     
    
    61
    -    EventCounter updatedSpin(m_spin.get(), wxEVT_SPINCTRLDOUBLE);
    
    62
    -    EventCounter updatedText(m_spin.get(), wxEVT_TEXT);
    
    61
    +    EventCounter updatedSpin(spin.get(), wxEVT_SPINCTRLDOUBLE);
    
    62
    +    EventCounter updatedText(spin.get(), wxEVT_TEXT);
    
    63 63
     
    
    64
    -    m_spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "",
    
    64
    +    spin->Create(wxTheApp->GetTopWindow(), wxID_ANY, "",
    
    65 65
                        wxDefaultPosition, wxDefaultSize, 0,
    
    66 66
                        0., 100., 17.);
    
    67 67
     
    

Reply all
Reply to author
Forward
0 new messages