Add immediate mode to WX_HTML_REPORT_BOX for use as progress messages.

Fixes https://gitlab.com/kicad/code/kicad/issues/6052
This commit is contained in:
Jeff Young 2020-10-18 12:51:36 +01:00
parent b28f397614
commit 8c68857f02
7 changed files with 36 additions and 19 deletions

View File

@ -34,6 +34,10 @@ WX_HTML_REPORT_BOX::WX_HTML_REPORT_BOX( wxWindow* parent, wxWindowID id, const w
REPORTER& WX_HTML_REPORT_BOX::Report( const wxString& aText, SEVERITY aSeverity )
{
m_messages.push_back( aText );
if( m_immediateMode )
Flush();
return *this;
}

View File

@ -44,6 +44,8 @@ public:
void SetUnits( EDA_UNITS aUnits ) { m_units = aUnits; }
EDA_UNITS GetUnits() const override { return m_units; }
void SetImmediateMode() { m_immediateMode = true; }
void Flush();
void Clear();
@ -53,6 +55,10 @@ private:
EDA_UNITS m_units;
// Indicates messages should be flushed as they are added. Required for progress-related
// reports, but can be very slow for larger reports.
bool m_immediateMode;
///> copy of the report, stored for filtering
std::vector<wxString> m_messages;
};

View File

@ -96,8 +96,13 @@ wxSize WX_ANGLE_TEXT::GetTextSize( wxWindow* aWindow, const wxString& aLabel )
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
#ifdef __WXMAC__
// Rotated text looks visually smaller on OSX
// Rotated text looks visually smaller on OSX...
font.SetPointSize( font.GetPointSize() + 2 );
#elif __WXGTK3__
// TODO: needs testing...
#else
// ... but larger on MSW
font.SetPointSize( font.GetPointSize() - 2 );
#endif
// Measure the size of the text

View File

@ -63,6 +63,8 @@ DIALOG_DRC::DIALOG_DRC( PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ) :
m_brdEditor = aEditorFrame;
m_currentBoard = m_brdEditor->GetBoard();
m_messages->SetImmediateMode();
m_markerTreeModel = new RC_TREE_MODEL( m_brdEditor, m_markerDataView );
m_markerDataView->AssociateModel( m_markerTreeModel );
@ -167,7 +169,7 @@ void DIALOG_DRC::AdvancePhase( const wxString& aMessage )
PROGRESS_REPORTER::AdvancePhase( aMessage );
SetCurrentProgress( 0.0 );
m_Messages->Report( aMessage + "<br>" );
m_messages->Report( aMessage );
}
@ -217,12 +219,12 @@ void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
m_DeleteAllMarkersButton->Enable( false );
m_saveReport->Enable( false );
m_Messages->Clear();
m_Messages->Report( _( "DRC incomplete: could not compile design rules. " )
m_messages->Clear();
m_messages->Report( _( "DRC incomplete: could not compile design rules. " )
+ wxT( "<a href='boardsetup'>" )
+ _( "Show design rules." )
+ wxT( "</a>" ) );
m_Messages->Flush();
m_messages->Flush();
Raise();
return;
@ -240,7 +242,7 @@ void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
Raise();
m_runningResultsBook->ChangeSelection( 0 ); // Display the "Tests Running..." tab
m_Messages->Clear();
m_messages->Clear();
wxYield(); // Allow time slice to refresh Messages
m_running = true;
@ -254,9 +256,9 @@ void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
testFootprints );
if( m_cancelled )
m_Messages->Report( _( "-------- DRC cancelled by user.<br><br>" ) );
m_messages->Report( _( "-------- DRC cancelled by user.<br><br>" ) );
else
m_Messages->Report( _( "Done.<br><br>" ) );
m_messages->Report( _( "Done.<br><br>" ) );
Raise();
wxYield(); // Allow time slice to refresh Messages
@ -592,12 +594,12 @@ void DIALOG_DRC::OnSaveReport( wxCommandEvent& aEvent )
if( writeReport( fn.GetFullPath() ) )
{
m_Messages->Report( wxString::Format( _( "Report file '%s' created<br>" ),
m_messages->Report( wxString::Format( _( "Report file '%s' created<br>" ),
fn.GetFullPath() ) );
}
else
{
DisplayError( this, wxString::Format( _( "Unable to create report file '%s'" ),
DisplayError( this, wxString::Format( _( "Unable to create report file '%s'<br>" ),
fn.GetFullPath() ) );
}
}

View File

@ -62,8 +62,8 @@ DIALOG_DRC_BASE::DIALOG_DRC_BASE( wxWindow* parent, wxWindowID id, const wxStrin
wxBoxSizer* bSizer10;
bSizer10 = new wxBoxSizer( wxVERTICAL );
m_Messages = new WX_HTML_REPORT_BOX( m_panelMessages, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
bSizer10->Add( m_Messages, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_messages = new WX_HTML_REPORT_BOX( m_panelMessages, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
bSizer10->Add( m_messages, 1, wxEXPAND | wxTOP | wxRIGHT | wxLEFT, 5 );
wxBoxSizer* bGaugeMargins;
bGaugeMargins = new wxBoxSizer( wxVERTICAL );
@ -224,7 +224,7 @@ DIALOG_DRC_BASE::DIALOG_DRC_BASE( wxWindow* parent, wxWindowID id, const wxStrin
// Connect Events
this->Connect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_DRC_BASE::OnActivateDlg ) );
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_DRC_BASE::OnClose ) );
m_Messages->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DRC_BASE::OnErrorLinkClicked ), NULL, this );
m_messages->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DRC_BASE::OnErrorLinkClicked ), NULL, this );
m_Notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_BASE::OnChangingNotebookPage ), NULL, this );
m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemDClick ), NULL, this );
m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemRClick ), NULL, this );
@ -249,7 +249,7 @@ DIALOG_DRC_BASE::~DIALOG_DRC_BASE()
// Disconnect Events
this->Disconnect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_DRC_BASE::OnActivateDlg ) );
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_DRC_BASE::OnClose ) );
m_Messages->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DRC_BASE::OnErrorLinkClicked ), NULL, this );
m_messages->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DRC_BASE::OnErrorLinkClicked ), NULL, this );
m_Notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_BASE::OnChangingNotebookPage ), NULL, this );
m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemDClick ), NULL, this );
m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemRClick ), NULL, this );

View File

@ -619,7 +619,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_Messages</property>
<property name="name">m_messages</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>

View File

@ -56,7 +56,7 @@ class DIALOG_DRC_BASE : public DIALOG_SHIM
wxPanel* running;
wxNotebook* m_runningNotebook;
wxPanel* m_panelMessages;
WX_HTML_REPORT_BOX* m_Messages;
WX_HTML_REPORT_BOX* m_messages;
wxGauge* m_gauge;
wxPanel* results;
wxNotebook* m_Notebook;