Remove creation on the fly of wxPaintEvent instances, not allowed in 3.1.4 wxWidgets
From master branch
This commit is contained in:
parent
ee6154c842
commit
284d5861dd
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -57,6 +57,9 @@ const wxChar * EDA_3D_CANVAS::m_logTrace = wxT( "KI_TRACE_EDA_3D_CANVAS" );
|
|||
|
||||
const float EDA_3D_CANVAS::m_delta_move_step_factor = 0.7f;
|
||||
|
||||
// A custom event, used to call DoRePaint during an idle time
|
||||
wxDEFINE_EVENT( wxEVT_REFRESH_CUSTOM_COMMAND, wxEvent);
|
||||
|
||||
|
||||
BEGIN_EVENT_TABLE( EDA_3D_CANVAS, wxGLCanvas )
|
||||
EVT_PAINT( EDA_3D_CANVAS::OnPaint )
|
||||
|
@ -78,6 +81,7 @@ BEGIN_EVENT_TABLE( EDA_3D_CANVAS, wxGLCanvas )
|
|||
|
||||
// other events
|
||||
EVT_ERASE_BACKGROUND( EDA_3D_CANVAS::OnEraseBackground )
|
||||
EVT_CUSTOM(wxEVT_REFRESH_CUSTOM_COMMAND, ID_CUSTOM_EVENT_1, EDA_3D_CANVAS::OnRefreshRequest )
|
||||
EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START,
|
||||
ID_POPUP_3D_VIEW_END, EDA_3D_CANVAS::OnPopUpMenu )
|
||||
|
||||
|
@ -312,17 +316,22 @@ void EDA_3D_CANVAS::DisplayStatus()
|
|||
}
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event )
|
||||
void EDA_3D_CANVAS::OnPaint( wxPaintEvent& aEvent )
|
||||
{
|
||||
// Please have a look at:
|
||||
// https://lists.launchpad.net/kicad-developers/msg25149.html
|
||||
// wxPaintDC( this );
|
||||
// event.Skip( false );
|
||||
// aEvent.Skip( false );
|
||||
DoRePaint();
|
||||
}
|
||||
|
||||
|
||||
void EDA_3D_CANVAS::DoRePaint()
|
||||
{
|
||||
// SwapBuffer requires the window to be shown before calling
|
||||
if( !IsShownOnScreen() )
|
||||
{
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::OnPaint !IsShown" );
|
||||
wxLogTrace( m_logTrace, "EDA_3D_CANVAS::DoRePaint !IsShown" );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -856,13 +865,13 @@ void EDA_3D_CANVAS::restart_editingTimeOut_Timer()
|
|||
|
||||
void EDA_3D_CANVAS::OnTimerTimeout_Redraw( wxTimerEvent &event )
|
||||
{
|
||||
(void)event;
|
||||
Request_refresh( true );
|
||||
}
|
||||
|
||||
//Refresh();
|
||||
//Update();
|
||||
|
||||
wxPaintEvent redrawEvent;
|
||||
wxPostEvent( this, redrawEvent );
|
||||
void EDA_3D_CANVAS::OnRefreshRequest( wxEvent& aEvent )
|
||||
{
|
||||
DoRePaint();
|
||||
}
|
||||
|
||||
|
||||
|
@ -870,22 +879,12 @@ void EDA_3D_CANVAS::Request_refresh( bool aRedrawImmediately )
|
|||
{
|
||||
if( aRedrawImmediately )
|
||||
{
|
||||
// On some systems, just calling Refresh does not work always
|
||||
// (Issue experienced on Win7 MSYS2)
|
||||
//Refresh();
|
||||
//Update();
|
||||
|
||||
// Using PostEvent will take priority to other events, like
|
||||
// mouse movements, keys, etc.
|
||||
wxPaintEvent redrawEvent;
|
||||
// Just calling Refresh() does not work always
|
||||
// Using an event to call DoRepaint ensure the repaint code will be executed,
|
||||
// and PostEvent will take priority to other events like mouse movements, keys, etc.
|
||||
// and is executed during the next idle time
|
||||
wxCommandEvent redrawEvent( wxEVT_REFRESH_CUSTOM_COMMAND, ID_CUSTOM_EVENT_1 );
|
||||
wxPostEvent( this, redrawEvent );
|
||||
|
||||
// This behaves the same
|
||||
// wxQueueEvent( this,
|
||||
// From wxWidget documentation: "The heap-allocated and
|
||||
// non-NULL event to queue, the function takes ownership of it."
|
||||
// new wxPaintEvent()
|
||||
// );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -135,10 +135,21 @@ class EDA_3D_CANVAS : public HIDPI_GL_CANVAS
|
|||
|
||||
private:
|
||||
|
||||
void OnPaint( wxPaintEvent &event );
|
||||
/** Called by a wxPaintEvent event
|
||||
*/
|
||||
void OnPaint( wxPaintEvent& aEvent );
|
||||
|
||||
/**
|
||||
* The actual function to repaint the canvas.
|
||||
* It is usually called by OnPaint() but because it does not use a wxPaintDC
|
||||
* it can be called outside a wxPaintEvent
|
||||
*/
|
||||
void DoRePaint();
|
||||
|
||||
void OnEraseBackground( wxEraseEvent &event );
|
||||
|
||||
void OnRefreshRequest( wxEvent& aEvent );
|
||||
|
||||
void OnMouseWheel( wxMouseEvent &event );
|
||||
|
||||
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
|
||||
|
|
|
@ -103,6 +103,8 @@ enum id_3dview_frm
|
|||
|
||||
ID_DISABLE_RAY_TRACING,
|
||||
|
||||
ID_CUSTOM_EVENT_1, // A id for a custom event (canvas refresh request)
|
||||
|
||||
ID_POPUP_3D_VIEW_START,
|
||||
ID_POPUP_ZOOMIN,
|
||||
ID_POPUP_ZOOMOUT,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2017 CERN
|
||||
* Copyright (C) 2013-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -148,6 +148,16 @@ void EDA_DRAW_PANEL_GAL::SetFocus()
|
|||
|
||||
void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
||||
{
|
||||
DoRePaint();
|
||||
}
|
||||
|
||||
|
||||
void EDA_DRAW_PANEL_GAL::DoRePaint()
|
||||
{
|
||||
// Repaint the canvas, and fix scrollbar cursors
|
||||
// Usually called by a OnPaint event, but because it does not use a wxPaintDC,
|
||||
// it can be called outside a wxPaintEvent.
|
||||
|
||||
// Update current zoom settings if the canvas is managed by a EDA frame
|
||||
// (i.e. not by a preview panel in a dialog)
|
||||
if( GetParentEDAFrame() && GetParentEDAFrame()->GetScreen() )
|
||||
|
@ -231,7 +241,7 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
|||
|
||||
#ifdef __WXDEBUG__
|
||||
totalRealTime.Stop();
|
||||
wxLogTrace( "GAL_PROFILE", "EDA_DRAW_PANEL_GAL::onPaint(): %.1f ms", totalRealTime.msecs() );
|
||||
wxLogTrace( "GAL_PROFILE", "EDA_DRAW_PANEL_GAL::DoRePaint(): %.1f ms", totalRealTime.msecs() );
|
||||
#endif /* PROFILE */
|
||||
|
||||
m_lastRefresh = wxGetLocalTimeMillis();
|
||||
|
@ -284,8 +294,9 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool aEraseBackground, const wxRect* aRect )
|
|||
|
||||
void EDA_DRAW_PANEL_GAL::ForceRefresh()
|
||||
{
|
||||
wxPaintEvent redrawEvent;
|
||||
wxPostEvent( this, redrawEvent );
|
||||
//wxPaintEvent redrawEvent;
|
||||
//wxPostEvent( this, redrawEvent );
|
||||
DoRePaint();
|
||||
}
|
||||
|
||||
|
||||
|
@ -495,8 +506,9 @@ void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
wxPaintEvent redrawEvent;
|
||||
wxPostEvent( this, redrawEvent );
|
||||
//wxPaintEvent redrawEvent;
|
||||
//wxPostEvent( this, redrawEvent );
|
||||
DoRePaint();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1297,6 +1297,16 @@ void CAIRO_GAL::endDrawing()
|
|||
}
|
||||
|
||||
|
||||
void CAIRO_GAL::PostPaint( wxPaintEvent& aEvent )
|
||||
{
|
||||
// posts an event to m_paint_listener to ask for redraw the canvas.
|
||||
if( paintListener )
|
||||
{
|
||||
wxPostEvent( paintListener, aEvent );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CAIRO_GAL::ResizeScreen( int aWidth, int aHeight )
|
||||
{
|
||||
CAIRO_GAL_BASE::ResizeScreen( aWidth, aHeight );
|
||||
|
@ -1502,9 +1512,9 @@ void CAIRO_GAL::setCompositor()
|
|||
}
|
||||
|
||||
|
||||
void CAIRO_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
||||
void CAIRO_GAL::onPaint( wxPaintEvent& aEvent )
|
||||
{
|
||||
PostPaint();
|
||||
PostPaint( aEvent );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -326,6 +326,16 @@ OPENGL_GAL::~OPENGL_GAL()
|
|||
}
|
||||
|
||||
|
||||
void OPENGL_GAL::PostPaint( wxPaintEvent& aEvent )
|
||||
{
|
||||
// posts an event to m_paint_listener to ask for redraw the canvas.
|
||||
if( paintListener )
|
||||
{
|
||||
wxPostEvent( paintListener, aEvent );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool OPENGL_GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions )
|
||||
{
|
||||
bool refresh = false;
|
||||
|
@ -1911,9 +1921,9 @@ std::pair<VECTOR2D, float> OPENGL_GAL::computeBitmapTextSize( const UTF8& aText
|
|||
}
|
||||
|
||||
|
||||
void OPENGL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
||||
void OPENGL_GAL::onPaint( wxPaintEvent& aEvent )
|
||||
{
|
||||
PostPaint();
|
||||
PostPaint( aEvent );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013-2018 CERN
|
||||
* Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -240,7 +242,15 @@ public:
|
|||
*/
|
||||
void OnEvent( wxEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Repaint the canvas, and fix scrollbar cursors
|
||||
* Usually called by a OnPaint event, but because it do not use a wxPaintDC,
|
||||
* it can be called outside a wxPaintEvent.
|
||||
*/
|
||||
void DoRePaint();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void onPaint( wxPaintEvent& WXUNUSED( aEvent ) );
|
||||
void onSize( wxSizeEvent& aEvent );
|
||||
void onEnter( wxEvent& aEvent );
|
||||
|
|
|
@ -390,16 +390,10 @@ public:
|
|||
/**
|
||||
* Function PostPaint
|
||||
* posts an event to m_paint_listener. A post is used so that the actual drawing
|
||||
* function can use a device context type that is not specific to the wxEVT_PAINT event.
|
||||
* function can use a device context type that is not specific to the wxEVT_PAINT event,
|
||||
* just by changing the PostPaint code.
|
||||
*/
|
||||
void PostPaint()
|
||||
{
|
||||
if( paintListener )
|
||||
{
|
||||
wxPaintEvent redrawEvent;
|
||||
wxPostEvent( paintListener, redrawEvent );
|
||||
}
|
||||
}
|
||||
void PostPaint( wxPaintEvent& aEvent );
|
||||
|
||||
void SetMouseListener( wxEvtHandler* aMouseListener )
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
|
||||
* Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2020 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2013-2017 CERN
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -249,16 +249,10 @@ public:
|
|||
/**
|
||||
* @brief Function PostPaint
|
||||
* posts an event to m_paint_listener. A post is used so that the actual drawing
|
||||
* function can use a device context type that is not specific to the wxEVT_PAINT event.
|
||||
* function can use a device context type that is not specific to the wxEVT_PAINT event,
|
||||
* just by changing the PostPaint code.
|
||||
*/
|
||||
void PostPaint()
|
||||
{
|
||||
if( paintListener )
|
||||
{
|
||||
wxPaintEvent redrawEvent;
|
||||
wxPostEvent( paintListener, redrawEvent );
|
||||
}
|
||||
}
|
||||
void PostPaint( wxPaintEvent& aEvent );
|
||||
|
||||
void SetMouseListener( wxEvtHandler* aMouseListener )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue