Add wxWindow parameter to wxAuiTabArt::SetSizingInfo()

We need a valid window pointer to use the correct DPI scaling factor for
anything sizing-related, but this function didn't have any, so add one
to it now.

Unfortunately we need to have a default value for the new parameter for
backwards-compatibility purposes, but document that this parameter is
not really optional and must always be specified.

Also add wxWindow parameter to wxAuiTabContainer::SetRect(), which needs
it in order to pass it to this function.

Currently this window is only used for converting logical pixels to
physical ones, but it will also be used for selecting the correct bitmap
size in the upcoming commits.
This commit is contained in:
Vadim Zeitlin
2021-11-13 23:20:21 +00:00
parent 0b51dfe134
commit 8dcedf56d7
5 changed files with 46 additions and 17 deletions

View File

@@ -151,7 +151,7 @@ public:
void SetColour(const wxColour& colour);
void SetActiveColour(const wxColour& colour);
void DoShowHide();
void SetRect(const wxRect& rect);
void SetRect(const wxRect& rect, wxWindow* wnd = NULL);
void RemoveButton(int id);
void AddButton(int id,
@@ -200,6 +200,8 @@ public:
bool IsDragging() const { return m_isDragging; }
void SetRect(const wxRect& rect) { wxAuiTabContainer::SetRect(rect, this); }
protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const wxOVERRIDE { return wxBORDER_NONE; }

View File

@@ -47,7 +47,8 @@ public:
virtual void SetFlags(unsigned int flags) = 0;
virtual void SetSizingInfo(const wxSize& tabCtrlSize,
size_t tabCount) = 0;
size_t tabCount,
wxWindow* wnd = NULL) = 0;
virtual void SetNormalFont(const wxFont& font) = 0;
virtual void SetSelectedFont(const wxFont& font) = 0;
@@ -126,7 +127,8 @@ public:
wxAuiTabArt* Clone() wxOVERRIDE;
void SetFlags(unsigned int flags) wxOVERRIDE;
void SetSizingInfo(const wxSize& tabCtrlSize,
size_t tabCount) wxOVERRIDE;
size_t tabCount,
wxWindow* wnd = NULL) wxOVERRIDE;
void SetNormalFont(const wxFont& font) wxOVERRIDE;
void SetSelectedFont(const wxFont& font) wxOVERRIDE;
@@ -228,7 +230,8 @@ public:
void SetFlags(unsigned int flags) wxOVERRIDE;
void SetSizingInfo(const wxSize& tabCtrlSize,
size_t tabCount) wxOVERRIDE;
size_t tabCount,
wxWindow* wnd = NULL) wxOVERRIDE;
void SetNormalFont(const wxFont& font) wxOVERRIDE;
void SetSelectedFont(const wxFont& font) wxOVERRIDE;

View File

@@ -534,7 +534,7 @@ public:
void SetColour(const wxColour& colour);
void SetActiveColour(const wxColour& colour);
void DoShowHide();
void SetRect(const wxRect& rect);
void SetRect(const wxRect& rect, wxWindow* wnd = NULL);
void RemoveButton(int id);
void AddButton(int id,
@@ -672,8 +672,13 @@ public:
/**
Sets sizing information.
The @a wnd argument is only present in wxWidgets 3.1.6 and newer and is
required, it only has @NULL default value for compatibility reasons.
*/
virtual void SetSizingInfo(const wxSize& tab_ctrl_size, size_t tab_count) = 0;
virtual void SetSizingInfo(const wxSize& tab_ctrl_size,
size_t tab_count,
wxWindow* wnd = NULL) = 0;
};
/**
@@ -767,7 +772,8 @@ public:
wxAuiTabArt* Clone();
void SetFlags(unsigned int flags);
void SetSizingInfo(const wxSize& tabCtrlSize,
size_t tabCount);
size_t tabCount,
wxWindow* wnd = NULL);
void SetNormalFont(const wxFont& font);
void SetSelectedFont(const wxFont& font);
@@ -872,7 +878,8 @@ public:
void SetFlags(unsigned int flags);
void SetSizingInfo(const wxSize& tabCtrlSize,
size_t tabCount);
size_t tabCount,
wxWindow* wnd = NULL);
void SetNormalFont(const wxFont& font);
void SetSelectedFont(const wxFont& font);

View File

@@ -168,13 +168,13 @@ void wxAuiTabContainer::SetActiveColour(const wxColour& colour)
m_art->SetActiveColour(colour);
}
void wxAuiTabContainer::SetRect(const wxRect& rect)
void wxAuiTabContainer::SetRect(const wxRect& rect, wxWindow* wnd)
{
m_rect = rect;
if (m_art)
{
m_art->SetSizingInfo(rect.GetSize(), m_pages.GetCount());
m_art->SetSizingInfo(rect.GetSize(), m_pages.GetCount(), wnd);
}
}
@@ -191,7 +191,7 @@ bool wxAuiTabContainer::AddPage(wxWindow* page,
// let the art provider know how many pages we have
if (m_art)
{
m_art->SetSizingInfo(m_rect.GetSize(), m_pages.GetCount());
m_art->SetSizingInfo(m_rect.GetSize(), m_pages.GetCount(), page);
}
return true;
@@ -214,7 +214,7 @@ bool wxAuiTabContainer::InsertPage(wxWindow* page,
// let the art provider know how many pages we have
if (m_art)
{
m_art->SetSizingInfo(m_rect.GetSize(), m_pages.GetCount());
m_art->SetSizingInfo(m_rect.GetSize(), m_pages.GetCount(), page);
}
return true;
@@ -252,7 +252,7 @@ bool wxAuiTabContainer::RemovePage(wxWindow* wnd)
// let the art provider know how many pages we have
if (m_art)
{
m_art->SetSizingInfo(m_rect.GetSize(), m_pages.GetCount());
m_art->SetSizingInfo(m_rect.GetSize(), m_pages.GetCount(), wnd);
}
return true;

View File

@@ -18,6 +18,7 @@
#if wxUSE_AUI
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
#include "wx/settings.h"
@@ -232,9 +233,18 @@ void wxAuiGenericTabArt::SetFlags(unsigned int flags)
}
void wxAuiGenericTabArt::SetSizingInfo(const wxSize& tab_ctrl_size,
size_t tab_count)
size_t tab_count,
wxWindow* wnd)
{
m_fixedTabWidth = wxWindow::FromDIP(100, NULL);
if ( !wnd )
{
// This is only allowed for backwards compatibility, we should be
// really passed a valid window.
wnd = wxTheApp->GetTopWindow();
wxCHECK_RET( wnd, "must have some window" );
}
m_fixedTabWidth = wnd->FromDIP(100);
int tot_width = (int)tab_ctrl_size.x - GetIndentSize() - wxWindow::FromDIP(4, NULL);
@@ -948,9 +958,16 @@ void wxAuiSimpleTabArt::SetFlags(unsigned int flags)
}
void wxAuiSimpleTabArt::SetSizingInfo(const wxSize& tab_ctrl_size,
size_t tab_count)
size_t tab_count,
wxWindow* wnd)
{
m_fixedTabWidth = wxWindow::FromDIP(100, NULL);
if ( !wnd )
{
wnd = wxTheApp->GetTopWindow();
wxCHECK_RET( wnd, "must have some window" );
}
m_fixedTabWidth = wnd->FromDIP(100);
int tot_width = (int)tab_ctrl_size.x - GetIndentSize() - wxWindow::FromDIP(4, NULL);