mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-18 01:19:45 +08:00
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:
@@ -1882,6 +1882,8 @@ private:
|
||||
|
||||
bool ButtonTriggerKeyTest(wxPGKeyboardAction action, wxKeyEvent& event);
|
||||
|
||||
void ReallocDoubleBufferIfNeeded();
|
||||
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
|
||||
+33
-28
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user