Skip to content

Commit

Permalink
Fix AUI tab close button size after DPI change in wxMSW
Browse files Browse the repository at this point in the history
Reset close button size on DPI change to ensure that its size is
recomputed correctly using the new DPI when the tab is redrawn the next
time.

Closes #23400.
  • Loading branch information
Kumazuma authored and vadz committed Mar 30, 2023
1 parent d5b61a1 commit baa2ea0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/wx/aui/auibook.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl,
void OnChar(wxKeyEvent& event);
void OnCaptureLost(wxMouseCaptureLostEvent& evt);
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnDpiChanged(wxDPIChangedEvent& event);

protected:

Expand Down
1 change: 1 addition & 0 deletions include/wx/aui/tabart.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class WXDLLIMPEXP_AUI wxAuiTabArt

// Provide opportunity for subclasses to recalculate colours
virtual void UpdateColoursFromSystem() {}
virtual void UpdateDpi() {}
};


Expand Down
2 changes: 2 additions & 0 deletions include/wx/aui/tabartmsw.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class WXDLLIMPEXP_AUI wxAuiMSWTabArt : public wxAuiGenericTabArt
const wxAuiNotebookPageArray& pages,
const wxSize& requiredBmpSize) override;

void UpdateDpi() override;

private:
bool m_themed;
wxSize m_closeBtnSize;
Expand Down
7 changes: 7 additions & 0 deletions src/aui/auibook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@ wxBEGIN_EVENT_TABLE(wxAuiTabCtrl, wxControl)
EVT_CHAR(wxAuiTabCtrl::OnChar)
EVT_MOUSE_CAPTURE_LOST(wxAuiTabCtrl::OnCaptureLost)
EVT_SYS_COLOUR_CHANGED(wxAuiTabCtrl::OnSysColourChanged)
EVT_DPI_CHANGED(wxAuiTabCtrl::OnDpiChanged)
wxEND_EVENT_TABLE()


Expand Down Expand Up @@ -1505,6 +1506,12 @@ void wxAuiTabCtrl::OnChar(wxKeyEvent& event)
event.Skip();
}

void wxAuiTabCtrl::OnDpiChanged(wxDPIChangedEvent& event)
{
m_art->UpdateDpi();
event.Skip();
}

// wxTabFrame is an interesting case. It's important that all child pages
// of the multi-notebook control are all actually children of that control
// (and not grandchildren). wxTabFrame facilitates this. There is one
Expand Down
4 changes: 4 additions & 0 deletions src/aui/tabartmsw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,5 +458,9 @@ bool wxAuiMSWTabArt::IsThemed() const
!(m_flags & wxAUI_NB_BOTTOM); // Native theme does not support bottom tabs
}

void wxAuiMSWTabArt::UpdateDpi()
{
m_closeBtnSize = wxDefaultSize;
}

#endif // wxUSE_AUI && wxUSE_UXTHEME && !defined(__WXUNIVERSAL__)

0 comments on commit baa2ea0

Please sign in to comment.