Added lazy rendering mode for HTML reporter widget (allows a faster report creation, when the report has many lines)
This commit is contained in:
parent
9b9c7945a2
commit
e4c8854159
|
@ -32,7 +32,8 @@ WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent,
|
|||
WX_HTML_REPORT_PANEL_BASE( parent, id, pos, size, style ),
|
||||
m_reporter( this ),
|
||||
m_severities( -1 ),
|
||||
m_showAll( true )
|
||||
m_showAll( true ),
|
||||
m_lazyUpdate( false )
|
||||
{
|
||||
syncCheckboxes();
|
||||
m_htmlView->SetPage( addHeader( "" ) );
|
||||
|
@ -57,7 +58,26 @@ void WX_HTML_REPORT_PANEL::Report( const wxString& aText, REPORTER::SEVERITY aSe
|
|||
line.severity = aSeverity;
|
||||
|
||||
m_report.push_back( line );
|
||||
m_htmlView->AppendToPage( generateHtml( line ) );
|
||||
|
||||
m_html += generateHtml( line );
|
||||
|
||||
if( !m_lazyUpdate )
|
||||
{
|
||||
m_htmlView->AppendToPage( generateHtml( line ) );
|
||||
scrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WX_HTML_REPORT_PANEL::SetLazyUpdate( bool aLazyUpdate )
|
||||
{
|
||||
m_lazyUpdate = aLazyUpdate;
|
||||
}
|
||||
|
||||
|
||||
void WX_HTML_REPORT_PANEL::Flush()
|
||||
{
|
||||
m_htmlView->SetPage( m_html );
|
||||
scrollToBottom();
|
||||
}
|
||||
|
||||
|
@ -65,6 +85,7 @@ void WX_HTML_REPORT_PANEL::Report( const wxString& aText, REPORTER::SEVERITY aSe
|
|||
void WX_HTML_REPORT_PANEL::scrollToBottom()
|
||||
{
|
||||
int x, y, xUnit, yUnit;
|
||||
|
||||
m_htmlView->GetVirtualSize( &x, &y );
|
||||
m_htmlView->GetScrollPixelsPerUnit( &xUnit, &yUnit );
|
||||
m_htmlView->Scroll( 0, y / yUnit );
|
||||
|
@ -242,5 +263,12 @@ void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event )
|
|||
|
||||
void WX_HTML_REPORT_PANEL::Clear()
|
||||
{
|
||||
m_html.clear();
|
||||
m_report.clear();
|
||||
}
|
||||
|
||||
|
||||
void WX_HTML_REPORT_PANEL::SetLabel( const wxString& aLabel )
|
||||
{
|
||||
m_box->GetStaticBox()->SetLabel( aLabel );
|
||||
}
|
||||
|
|
|
@ -55,6 +55,24 @@ public:
|
|||
///> clears the report panel
|
||||
void Clear();
|
||||
|
||||
///> sets the frame label
|
||||
void SetLabel( const wxString& aLabel );
|
||||
|
||||
///> Sets the lasy update. If this mode is on, messages are stored but the display
|
||||
///> is not updated (Updating display can be very time consumming if there are many messages)
|
||||
///> A call to Flush() will be needed after build the report
|
||||
void SetLazyUpdate( bool aLazyUpdate );
|
||||
|
||||
///> Forces updating the HTML page, after the report is built in lazy mode
|
||||
void Flush();
|
||||
|
||||
void SetVisibleSeverities( int aSeverities )
|
||||
{
|
||||
m_showAll = false;
|
||||
m_severities = aSeverities;
|
||||
syncCheckboxes();
|
||||
}
|
||||
|
||||
private:
|
||||
struct REPORT_LINE
|
||||
{
|
||||
|
@ -91,6 +109,10 @@ private:
|
|||
|
||||
///> show all messages flag (overrides m_severities)
|
||||
bool m_showAll;
|
||||
|
||||
wxString m_html;
|
||||
|
||||
bool m_lazyUpdate;
|
||||
};
|
||||
|
||||
#endif //__WX_HTML_REPORT_PANEL_H__
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
|
||||
WX_HTML_REPORT_PANEL_BASE::WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )
|
||||
{
|
||||
wxStaticBoxSizer* sbSizer3;
|
||||
sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Messages:") ), wxVERTICAL );
|
||||
m_box = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxT("Messages:") ), wxVERTICAL );
|
||||
|
||||
wxFlexGridSizer* fgSizer4;
|
||||
fgSizer4 = new wxFlexGridSizer( 2, 1, 0, 0 );
|
||||
|
@ -67,10 +66,10 @@ WX_HTML_REPORT_PANEL_BASE::WX_HTML_REPORT_PANEL_BASE( wxWindow* parent, wxWindow
|
|||
fgSizer4->Add( fgSizer3, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
sbSizer3->Add( fgSizer4, 1, wxEXPAND|wxALL, 5 );
|
||||
m_box->Add( fgSizer4, 1, wxEXPAND|wxALL, 5 );
|
||||
|
||||
|
||||
this->SetSizer( sbSizer3 );
|
||||
this->SetSizer( m_box );
|
||||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
|
|
|
@ -82,9 +82,9 @@
|
|||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Messages:</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">sbSizer3</property>
|
||||
<property name="name">m_box</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<property name="permission">protected</property>
|
||||
<event name="OnUpdateUI"></event>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
|
|
|
@ -34,6 +34,7 @@ class WX_HTML_REPORT_PANEL_BASE : public wxPanel
|
|||
private:
|
||||
|
||||
protected:
|
||||
wxStaticBoxSizer* m_box;
|
||||
wxHtmlWindow* m_htmlView;
|
||||
wxStaticText* m_staticText3;
|
||||
wxCheckBox* m_checkBoxShowAll;
|
||||
|
|
|
@ -62,3 +62,20 @@ REPORTER& WX_HTML_PANEL_REPORTER::Report( const wxString& aText, SEVERITY aSever
|
|||
m_panel->Report( aText, aSeverity );
|
||||
return *this;
|
||||
}
|
||||
|
||||
REPORTER& NULL_REPORTER::Report( const wxString& aText, SEVERITY aSeverity )
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
REPORTER& NULL_REPORTER::GetInstance()
|
||||
{
|
||||
static REPORTER* s_nullReporter = NULL;
|
||||
|
||||
if( !s_nullReporter )
|
||||
{
|
||||
s_nullReporter = new NULL_REPORTER();
|
||||
}
|
||||
|
||||
return *s_nullReporter;
|
||||
}
|
||||
|
|
|
@ -147,4 +147,22 @@ public:
|
|||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED );
|
||||
};
|
||||
|
||||
/**
|
||||
* Class NULL_REPORTER
|
||||
*
|
||||
* A singleton reporter that reports to nowhere. Used as to simplify code by
|
||||
* avoiding the reportee to check for a non-NULL reporter object.
|
||||
*/
|
||||
class NULL_REPORTER : public REPORTER
|
||||
{
|
||||
public:
|
||||
NULL_REPORTER()
|
||||
{
|
||||
};
|
||||
|
||||
static REPORTER& GetInstance();
|
||||
|
||||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_UNDEFINED );
|
||||
};
|
||||
|
||||
#endif // _REPORTER_H_
|
||||
|
|
Loading…
Reference in New Issue