Opened 7 months ago

Closed 3 months ago

#18717 closed defect (fixed)

Some controls reports client size greater than total size

Reported by: awi Owned by: csomor
Priority: normal Milestone:
Component: wxOSX Version: dev-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: no


For some controls, like wxButton, wxChoice, wxGauge, GetClientSize() returns size greater than size returned by GetSize().
This issue is reproduced with this patch to minimal sample:

  • samples/minimal/minimal.cpp

    diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp
    a b MyFrame::MyFrame(const wxString& title) 
    178178    CreateStatusBar(2);
    179179    SetStatusText("Welcome to wxWidgets!");
    180180#endif // wxUSE_STATUSBAR
     181    wxPanel* p = new wxPanel(this);
     183    wxGauge* gauge = new wxGauge(p, wxID_ANY, 100, wxPoint(10, 10));
     184    wxSize sz = gauge->GetSize();
     185    wxSize szc = gauge->GetClientSize();
     186    wxASSERT(szc.x <= sz.x && szc.y <= sz.y);
     188    wxButton* but = new wxButton(p, wxID_ANY, "ABC", wxPoint(10, 40));
     189    sz = but->GetSize();
     190    szc = but->GetClientSize();
     191    wxASSERT(szc.x <= sz.x && szc.y <= sz.y);
     193    wxChoice* choice = new wxChoice(p, wxID_ANY, wxPoint(10, 70));
     194    sz = choice->GetSize();
     195    szc = choice->GetClientSize();
     196    wxASSERT(szc.x <= sz.x && szc.y <= sz.y);

Change History (5)

comment:1 Changed 3 months ago by csomor

  • Owner set to csomor
  • Status changed from new to accepted

comment:2 Changed 3 months ago by csomor

it's related to the layout insets, they result in a negative border size

comment:3 Changed 3 months ago by csomor

  • Status changed from accepted to infoneeded

comment:4 Changed 3 months ago by awi

  • Status changed from infoneeded to accepted

Indeed it's fixed after this change.

comment:5 Changed 3 months ago by Vadim Zeitlin <vadim@…>

  • Resolution set to fixed
  • Status changed from accepted to closed

In d58e3e3c/git-wxWidgets:

Fix returning wrong client size for some controls in wxOSX

Make sure we are not neglecting the layout insets, for controls like
button, choice and gauge, otherwise client sizes became larger than
control sizes.

Closes #18717.

Note: See TracTickets for help on using tickets.