From 6bfe6342fcaa91b63b24cf218175cb9c23e31a8e Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 11 Aug 2016 14:41:41 +0200 Subject: [PATCH] Simulator fixes for Windows --- eeschema/sim/ngspice.cpp | 6 ++++-- eeschema/sim/sim_plot_frame.cpp | 2 +- eeschema/sim/sim_plot_panel.cpp | 1 + eeschema/sim/simulate.cpp | 29 ++++++++++++++++++++++++++++- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/eeschema/sim/ngspice.cpp b/eeschema/sim/ngspice.cpp index 51510ed24b..bafc6792c6 100644 --- a/eeschema/sim/ngspice.cpp +++ b/eeschema/sim/ngspice.cpp @@ -30,13 +30,15 @@ #include #include -// TODO cmake modules to add include directory for ngspice - using namespace std; NGSPICE::NGSPICE() { +#ifdef __WINDOWS__ + m_dll = new wxDynamicLibrary( "libngspice-0.dll" ); +#else m_dll = new wxDynamicLibrary( "libngspice.so" ); +#endif assert( m_dll ); // Obtain function pointers diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 8fbc3c8a64..97889a5c05 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -124,7 +124,7 @@ void SIM_PLOT_FRAME::NewPlotPanel( SIM_TYPE aSimType ) SIM_PLOT_PANEL* plot = new SIM_PLOT_PANEL( aSimType, m_plotNotebook, wxID_ANY ); m_plotNotebook->AddPage( plot, - wxString::Format( wxT( "Plot%lu" ), m_plotNotebook->GetPageCount() + 1 ), true ); + wxString::Format( wxT( "Plot%u" ), (unsigned int) m_plotNotebook->GetPageCount() + 1 ), true ); } diff --git a/eeschema/sim/sim_plot_panel.cpp b/eeschema/sim/sim_plot_panel.cpp index 71cf2b6534..3f9b36a611 100644 --- a/eeschema/sim/sim_plot_panel.cpp +++ b/eeschema/sim/sim_plot_panel.cpp @@ -100,6 +100,7 @@ SIM_PLOT_PANEL::SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, wxWindowID id, : mpWindow( parent, id, pos, size, style ), m_colorIdx( 0 ), m_axis_x( nullptr ), m_axis_y1( nullptr ), m_axis_y2( nullptr ), m_type( aType ) { + EnableDoubleBuffer( true ); SetMargins( 10, 10, 10, 10 ); LimitView( true ); diff --git a/eeschema/sim/simulate.cpp b/eeschema/sim/simulate.cpp index 68d1ee5daf..7d0772687f 100644 --- a/eeschema/sim/simulate.cpp +++ b/eeschema/sim/simulate.cpp @@ -39,6 +39,8 @@ void SCH_EDIT_FRAME::OnSimulate( wxCommandEvent& event ) simFrame->SetSchFrame( this ); } +// I apologize for the following lines, but this is more or less what wxWidgets +// authors suggest (http://docs.wxwidgets.org/trunk/classwx_cursor.html) static const unsigned char cursor_probe[] = { 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x70, @@ -66,4 +68,29 @@ static const unsigned char cursor_probe_mask[] { 0x7c, 0x07, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 }; -const wxCursor SCH_EDIT_FRAME::CURSOR_PROBE( (const char*) cursor_probe, 31, 32, 0, 31, (const char*) cursor_probe_mask ); +#ifdef __WXMSW__ +struct CURSOR_PROBE_INIT +{ +public: + static wxImage& GetProbeImage() + { + static wxImage* probe_image = NULL; + + if( probe_image == NULL ) + { + wxBitmap probe_bitmap( (const char*) cursor_probe, 32, 32 ); + wxBitmap probe_mask_bitmap( (const char*) cursor_probe_mask, 32, 32 ); + probe_bitmap.SetMask( new wxMask( probe_mask_bitmap ) ); + probe_image = new wxImage( probe_bitmap.ConvertToImage() ); + probe_image->SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_X, 0 ); + probe_image->SetOption( wxIMAGE_OPTION_CUR_HOTSPOT_Y, 31 ); + } + + return *probe_image; + } +}; + +const wxCursor SCH_EDIT_FRAME::CURSOR_PROBE( CURSOR_PROBE_INIT::GetProbeImage() ); +#elif defined(__WXGTK__) or defined(__WXMOTIF__) +const wxCursor SCH_EDIT_FRAME::CURSOR_PROBE( (const char*) cursor_probe, 32, 32, 0, 31, (const char*) cursor_probe_mask ); +#endif