Factor out wxPropertyGrid::ReallocDoubleBufferIfNeeded()

No real changes, just extract the code (re)creating m_doubleBuffer into
its own function to allow for its reuse in the upcoming commit.
This commit is contained in:
Vadim Zeitlin
2026-06-02 01:32:40 +02:00
parent daf6282a9c
commit b8a8f2e3ff
2 changed files with 35 additions and 28 deletions
+2
View File
@@ -1882,6 +1882,8 @@ private:
bool ButtonTriggerKeyTest(wxPGKeyboardAction action, wxKeyEvent& event);
void ReallocDoubleBufferIfNeeded();
wxDECLARE_EVENT_TABLE();
};
+33 -28
View File
@@ -4561,6 +4561,38 @@ void wxPropertyGrid::RecalculateVirtualSize( int forceXPos )
// -----------------------------------------------------------------------
void wxPropertyGrid::ReallocDoubleBufferIfNeeded()
{
if ( !HasExtraStyle(wxPG_EX_NATIVE_DOUBLE_BUFFERING) )
{
double scaleFactor = GetDPIScaleFactor();
int dblh = (m_lineHeight*2);
if ( !m_doubleBuffer )
{
// Create double buffer bitmap to draw on, if none
int w = wxMax(m_width, FromDIP(250));
int h = wxMax(m_height + dblh, FromDIP(400));
m_doubleBuffer = new wxBitmap;
m_doubleBuffer->CreateWithLogicalSize( w, h, scaleFactor );
}
else
{
int w = m_doubleBuffer->GetLogicalWidth();
int h = m_doubleBuffer->GetLogicalHeight();
// Double buffer must be large enough
if ( w < m_width || h < (m_height+dblh) )
{
if ( w < m_width ) w = m_width;
if ( h < (m_height+dblh) ) h = m_height + dblh;
delete m_doubleBuffer;
m_doubleBuffer = new wxBitmap;
m_doubleBuffer->CreateWithLogicalSize( w, h, scaleFactor );
}
}
}
}
void wxPropertyGrid::OnResize( wxSizeEvent& event )
{
if ( !(m_iFlags & wxPG_FL_INITIALIZED) )
@@ -4572,34 +4604,7 @@ void wxPropertyGrid::OnResize( wxSizeEvent& event )
m_width = width;
m_height = height;
if ( !HasExtraStyle(wxPG_EX_NATIVE_DOUBLE_BUFFERING) )
{
double scaleFactor = GetDPIScaleFactor();
int dblh = (m_lineHeight*2);
if ( !m_doubleBuffer )
{
// Create double buffer bitmap to draw on, if none
int w = wxMax(width, FromDIP(250));
int h = wxMax(height + dblh, FromDIP(400));
m_doubleBuffer = new wxBitmap;
m_doubleBuffer->CreateWithLogicalSize( w, h, scaleFactor );
}
else
{
int w = m_doubleBuffer->GetLogicalWidth();
int h = m_doubleBuffer->GetLogicalHeight();
// Double buffer must be large enough
if ( w < width || h < (height+dblh) )
{
if ( w < width ) w = width;
if ( h < (height+dblh) ) h = height + dblh;
delete m_doubleBuffer;
m_doubleBuffer = new wxBitmap;
m_doubleBuffer->CreateWithLogicalSize( w, h, scaleFactor );
}
}
}
ReallocDoubleBufferIfNeeded();
m_pState->OnClientWidthChange( width, event.GetSize().x - m_ncWidth, true );
m_ncWidth = event.GetSize().x;