HTML_REPORTER dialog.
This commit is contained in:
parent
08d4e91f3b
commit
2a2b842707
|
@ -169,6 +169,7 @@ set( COMMON_DLG_SRCS
|
||||||
dialogs/dialog_grid_settings.cpp
|
dialogs/dialog_grid_settings.cpp
|
||||||
dialogs/dialog_grid_settings_base.cpp
|
dialogs/dialog_grid_settings_base.cpp
|
||||||
dialogs/dialog_hotkey_list.cpp
|
dialogs/dialog_hotkey_list.cpp
|
||||||
|
dialogs/dialog_HTML_reporter_base.cpp
|
||||||
dialogs/dialog_image_editor.cpp
|
dialogs/dialog_image_editor.cpp
|
||||||
dialogs/dialog_image_editor_base.cpp
|
dialogs/dialog_image_editor_base.cpp
|
||||||
dialogs/dialog_migrate_settings.cpp
|
dialogs/dialog_migrate_settings.cpp
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||||
|
// http://www.wxformbuilder.org/
|
||||||
|
//
|
||||||
|
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx_html_report_box.h"
|
||||||
|
|
||||||
|
#include "dialog_HTML_reporter_base.h"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
DIALOG_HTML_REPORTER::DIALOG_HTML_REPORTER( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
|
||||||
|
{
|
||||||
|
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||||
|
|
||||||
|
wxBoxSizer* bMainSizer;
|
||||||
|
bMainSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
m_Reporter = new WX_HTML_REPORT_BOX( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO|wxBORDER_SIMPLE );
|
||||||
|
m_Reporter->SetMinSize( wxSize( 480,360 ) );
|
||||||
|
|
||||||
|
bMainSizer->Add( m_Reporter, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 );
|
||||||
|
|
||||||
|
m_sdbSizer = new wxStdDialogButtonSizer();
|
||||||
|
m_sdbSizerOK = new wxButton( this, wxID_OK );
|
||||||
|
m_sdbSizer->AddButton( m_sdbSizerOK );
|
||||||
|
m_sdbSizer->Realize();
|
||||||
|
|
||||||
|
bMainSizer->Add( m_sdbSizer, 0, wxEXPAND|wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
this->SetSizer( bMainSizer );
|
||||||
|
this->Layout();
|
||||||
|
bMainSizer->Fit( this );
|
||||||
|
|
||||||
|
this->Centre( wxBOTH );
|
||||||
|
|
||||||
|
// Connect Events
|
||||||
|
m_Reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_HTML_REPORTER::OnErrorLinkClicked ), NULL, this );
|
||||||
|
}
|
||||||
|
|
||||||
|
DIALOG_HTML_REPORTER::~DIALOG_HTML_REPORTER()
|
||||||
|
{
|
||||||
|
// Disconnect Events
|
||||||
|
m_Reporter->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_HTML_REPORTER::OnErrorLinkClicked ), NULL, this );
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
|
<wxFormBuilder_Project>
|
||||||
|
<FileVersion major="1" minor="15" />
|
||||||
|
<object class="Project" expanded="1">
|
||||||
|
<property name="class_decoration"></property>
|
||||||
|
<property name="code_generation">C++</property>
|
||||||
|
<property name="disconnect_events">1</property>
|
||||||
|
<property name="disconnect_mode">source_name</property>
|
||||||
|
<property name="disconnect_php_events">0</property>
|
||||||
|
<property name="disconnect_python_events">0</property>
|
||||||
|
<property name="embedded_files_path">res</property>
|
||||||
|
<property name="encoding">UTF-8</property>
|
||||||
|
<property name="event_generation">connect</property>
|
||||||
|
<property name="file">dialog_HTML_reporter_base</property>
|
||||||
|
<property name="first_id">2240</property>
|
||||||
|
<property name="help_provider">none</property>
|
||||||
|
<property name="indent_with_spaces"></property>
|
||||||
|
<property name="internationalize">1</property>
|
||||||
|
<property name="name">DialogHTMLReporterBase</property>
|
||||||
|
<property name="namespace"></property>
|
||||||
|
<property name="path">.</property>
|
||||||
|
<property name="precompiled_header"></property>
|
||||||
|
<property name="relative_path">1</property>
|
||||||
|
<property name="skip_lua_events">1</property>
|
||||||
|
<property name="skip_php_events">1</property>
|
||||||
|
<property name="skip_python_events">1</property>
|
||||||
|
<property name="ui_table">UI</property>
|
||||||
|
<property name="use_enum">0</property>
|
||||||
|
<property name="use_microsoft_bom">0</property>
|
||||||
|
<object class="Dialog" expanded="1">
|
||||||
|
<property name="aui_managed">0</property>
|
||||||
|
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
|
||||||
|
<property name="bg"></property>
|
||||||
|
<property name="center">wxBOTH</property>
|
||||||
|
<property name="context_help"></property>
|
||||||
|
<property name="context_menu">1</property>
|
||||||
|
<property name="enabled">1</property>
|
||||||
|
<property name="event_handler">impl_virtual</property>
|
||||||
|
<property name="extra_style"></property>
|
||||||
|
<property name="fg"></property>
|
||||||
|
<property name="font"></property>
|
||||||
|
<property name="hidden">0</property>
|
||||||
|
<property name="id">wxID_ANY</property>
|
||||||
|
<property name="maximum_size"></property>
|
||||||
|
<property name="minimum_size"></property>
|
||||||
|
<property name="name">DIALOG_HTML_REPORTER</property>
|
||||||
|
<property name="pos"></property>
|
||||||
|
<property name="size"></property>
|
||||||
|
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||||
|
<property name="subclass">; ; forward_declare</property>
|
||||||
|
<property name="title">Report</property>
|
||||||
|
<property name="tooltip"></property>
|
||||||
|
<property name="window_extra_style"></property>
|
||||||
|
<property name="window_name"></property>
|
||||||
|
<property name="window_style"></property>
|
||||||
|
<object class="wxBoxSizer" expanded="1">
|
||||||
|
<property name="minimum_size"></property>
|
||||||
|
<property name="name">bMainSizer</property>
|
||||||
|
<property name="orient">wxVERTICAL</property>
|
||||||
|
<property name="permission">none</property>
|
||||||
|
<object class="sizeritem" expanded="1">
|
||||||
|
<property name="border">10</property>
|
||||||
|
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
|
||||||
|
<property name="proportion">1</property>
|
||||||
|
<object class="wxHtmlWindow" expanded="1">
|
||||||
|
<property name="BottomDockable">1</property>
|
||||||
|
<property name="LeftDockable">1</property>
|
||||||
|
<property name="RightDockable">1</property>
|
||||||
|
<property name="TopDockable">1</property>
|
||||||
|
<property name="aui_layer"></property>
|
||||||
|
<property name="aui_name"></property>
|
||||||
|
<property name="aui_position"></property>
|
||||||
|
<property name="aui_row"></property>
|
||||||
|
<property name="best_size"></property>
|
||||||
|
<property name="bg"></property>
|
||||||
|
<property name="caption"></property>
|
||||||
|
<property name="caption_visible">1</property>
|
||||||
|
<property name="center_pane">0</property>
|
||||||
|
<property name="close_button">1</property>
|
||||||
|
<property name="context_help"></property>
|
||||||
|
<property name="context_menu">1</property>
|
||||||
|
<property name="default_pane">0</property>
|
||||||
|
<property name="dock">Dock</property>
|
||||||
|
<property name="dock_fixed">0</property>
|
||||||
|
<property name="docking">Left</property>
|
||||||
|
<property name="enabled">1</property>
|
||||||
|
<property name="fg"></property>
|
||||||
|
<property name="floatable">1</property>
|
||||||
|
<property name="font"></property>
|
||||||
|
<property name="gripper">0</property>
|
||||||
|
<property name="hidden">0</property>
|
||||||
|
<property name="id">wxID_ANY</property>
|
||||||
|
<property name="max_size"></property>
|
||||||
|
<property name="maximize_button">0</property>
|
||||||
|
<property name="maximum_size"></property>
|
||||||
|
<property name="min_size"></property>
|
||||||
|
<property name="minimize_button">0</property>
|
||||||
|
<property name="minimum_size">480,360</property>
|
||||||
|
<property name="moveable">1</property>
|
||||||
|
<property name="name">m_Reporter</property>
|
||||||
|
<property name="pane_border">1</property>
|
||||||
|
<property name="pane_position"></property>
|
||||||
|
<property name="pane_size"></property>
|
||||||
|
<property name="permission">public</property>
|
||||||
|
<property name="pin_button">1</property>
|
||||||
|
<property name="pos"></property>
|
||||||
|
<property name="resize">Resizable</property>
|
||||||
|
<property name="show">1</property>
|
||||||
|
<property name="size"></property>
|
||||||
|
<property name="style">wxHW_SCROLLBAR_AUTO</property>
|
||||||
|
<property name="subclass">WX_HTML_REPORT_BOX; wx_html_report_box.h; forward_declare</property>
|
||||||
|
<property name="toolbar_pane">0</property>
|
||||||
|
<property name="tooltip"></property>
|
||||||
|
<property name="window_extra_style"></property>
|
||||||
|
<property name="window_name"></property>
|
||||||
|
<property name="window_style">wxBORDER_SIMPLE</property>
|
||||||
|
<event name="OnHtmlLinkClicked">OnErrorLinkClicked</event>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
<object class="sizeritem" expanded="1">
|
||||||
|
<property name="border">5</property>
|
||||||
|
<property name="flag">wxEXPAND|wxALL</property>
|
||||||
|
<property name="proportion">0</property>
|
||||||
|
<object class="wxStdDialogButtonSizer" expanded="1">
|
||||||
|
<property name="Apply">0</property>
|
||||||
|
<property name="Cancel">0</property>
|
||||||
|
<property name="ContextHelp">0</property>
|
||||||
|
<property name="Help">0</property>
|
||||||
|
<property name="No">0</property>
|
||||||
|
<property name="OK">1</property>
|
||||||
|
<property name="Save">0</property>
|
||||||
|
<property name="Yes">0</property>
|
||||||
|
<property name="minimum_size"></property>
|
||||||
|
<property name="name">m_sdbSizer</property>
|
||||||
|
<property name="permission">protected</property>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</wxFormBuilder_Project>
|
|
@ -0,0 +1,50 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||||
|
// http://www.wxformbuilder.org/
|
||||||
|
//
|
||||||
|
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/artprov.h>
|
||||||
|
#include <wx/xrc/xmlres.h>
|
||||||
|
#include <wx/intl.h>
|
||||||
|
class WX_HTML_REPORT_BOX;
|
||||||
|
|
||||||
|
#include <wx/html/htmlwin.h>
|
||||||
|
#include <wx/gdicmn.h>
|
||||||
|
#include <wx/font.h>
|
||||||
|
#include <wx/colour.h>
|
||||||
|
#include <wx/settings.h>
|
||||||
|
#include <wx/string.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/button.h>
|
||||||
|
#include <wx/dialog.h>
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Class DIALOG_HTML_REPORTER
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
class DIALOG_HTML_REPORTER : public wxDialog
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxStdDialogButtonSizer* m_sdbSizer;
|
||||||
|
wxButton* m_sdbSizerOK;
|
||||||
|
|
||||||
|
// Virtual event handlers, overide them in your derived class
|
||||||
|
virtual void OnErrorLinkClicked( wxHtmlLinkEvent& event ) { event.Skip(); }
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
WX_HTML_REPORT_BOX* m_Reporter;
|
||||||
|
|
||||||
|
DIALOG_HTML_REPORTER( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Report"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||||
|
~DIALOG_HTML_REPORTER();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
|
@ -18,12 +18,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <math/util.h>
|
||||||
|
#include <common.h>
|
||||||
#include "wx_html_report_box.h"
|
#include "wx_html_report_box.h"
|
||||||
|
|
||||||
|
|
||||||
WX_HTML_REPORT_BOX::WX_HTML_REPORT_BOX( wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
WX_HTML_REPORT_BOX::WX_HTML_REPORT_BOX( wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
||||||
const wxSize& size, long style ) :
|
const wxSize& size, long style ) :
|
||||||
wxHtmlWindow( parent, id, pos, size, style )
|
wxHtmlWindow( parent, id, pos, size, style ),
|
||||||
|
m_units( EDA_UNITS::MILLIMETRES )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +38,30 @@ REPORTER& WX_HTML_REPORT_BOX::Report( const wxString& aText, SEVERITY aSeverity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString fixLinespacing( wxHtmlCell* aCell, int aMinLinespacing )
|
||||||
|
{
|
||||||
|
// wxWidgets default linespacing is about 110% of font-height (which is way too small),
|
||||||
|
// and the default paragraph spacing is about 200% (which is too big). The heading,
|
||||||
|
// bullet lists, etc. line spacing is fine.
|
||||||
|
//
|
||||||
|
// And of course they provide no way to set it, which leaves us with very few options.
|
||||||
|
// Fortunately we know we're dealing mostly with single lines in the reporter so we apply
|
||||||
|
// an egregious hack and enforce a minimum linespacing for things ending in '.' (which
|
||||||
|
// normally won't include headings or bullet list items).
|
||||||
|
|
||||||
|
wxString content = aCell->ConvertToText( nullptr );
|
||||||
|
wxHtmlContainerCell* container = dynamic_cast<wxHtmlContainerCell*>( aCell );
|
||||||
|
|
||||||
|
for( wxHtmlCell* child = aCell->GetFirstChild(); child; child = child->GetNext() )
|
||||||
|
content += fixLinespacing( child, aMinLinespacing );
|
||||||
|
|
||||||
|
if( container && content.EndsWith( "." ) && container->GetHeight() < aMinLinespacing )
|
||||||
|
container->SetMinHeight( aMinLinespacing );
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void WX_HTML_REPORT_BOX::Flush()
|
void WX_HTML_REPORT_BOX::Flush()
|
||||||
{
|
{
|
||||||
wxString html;
|
wxString html;
|
||||||
|
@ -43,6 +70,11 @@ void WX_HTML_REPORT_BOX::Flush()
|
||||||
html += generateHtml( line );
|
html += generateHtml( line );
|
||||||
|
|
||||||
SetPage( addHeader( html ) );
|
SetPage( addHeader( html ) );
|
||||||
|
|
||||||
|
wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
||||||
|
int minLineHeight = KiROUND( font.GetPixelSize().y * 1.3 );
|
||||||
|
|
||||||
|
fixLinespacing( GetInternalRepresentation(), minLineHeight );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +83,11 @@ wxString WX_HTML_REPORT_BOX::addHeader( const wxString& aBody )
|
||||||
wxColour bgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
|
wxColour bgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
|
||||||
wxColour fgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
|
wxColour fgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
|
||||||
|
|
||||||
return wxString::Format( wxT( "<html><body bgcolor='%s' text='%s'>%s</body></html>" ),
|
return wxString::Format( wxT( "<html>"
|
||||||
|
" <body bgcolor='%s' text='%s'>"
|
||||||
|
" %s"
|
||||||
|
" </body>"
|
||||||
|
"</html>" ),
|
||||||
bgcolor.GetAsString( wxC2S_HTML_SYNTAX ),
|
bgcolor.GetAsString( wxC2S_HTML_SYNTAX ),
|
||||||
fgcolor.GetAsString( wxC2S_HTML_SYNTAX ),
|
fgcolor.GetAsString( wxC2S_HTML_SYNTAX ),
|
||||||
aBody );
|
aBody );
|
||||||
|
@ -60,7 +96,7 @@ wxString WX_HTML_REPORT_BOX::addHeader( const wxString& aBody )
|
||||||
|
|
||||||
wxString WX_HTML_REPORT_BOX::generateHtml( const wxString& aLine )
|
wxString WX_HTML_REPORT_BOX::generateHtml( const wxString& aLine )
|
||||||
{
|
{
|
||||||
return "<font size=3>" + aLine + "</font><br>";
|
return aLine + "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
/**
|
/**
|
||||||
* WX_HTML_REPORT_BOX
|
* WX_HTML_REPORT_BOX
|
||||||
*
|
*
|
||||||
* A slimmed down version of WX_HTML_REPORT_BOX
|
* A slimmed down version of WX_HTML_REPORT_PANEL
|
||||||
*/
|
*/
|
||||||
class WX_HTML_REPORT_BOX : public wxHtmlWindow, public REPORTER
|
class WX_HTML_REPORT_BOX : public wxHtmlWindow, public REPORTER
|
||||||
{
|
{
|
||||||
|
@ -41,6 +41,9 @@ public:
|
||||||
|
|
||||||
bool HasMessage() const override { return !m_messages.empty(); }
|
bool HasMessage() const override { return !m_messages.empty(); }
|
||||||
|
|
||||||
|
void SetUnits( EDA_UNITS aUnits ) { m_units = aUnits; }
|
||||||
|
EDA_UNITS GetUnits() const override { return m_units; }
|
||||||
|
|
||||||
void Flush();
|
void Flush();
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
|
@ -48,7 +51,7 @@ private:
|
||||||
wxString addHeader( const wxString& aBody );
|
wxString addHeader( const wxString& aBody );
|
||||||
wxString generateHtml( const wxString& aLine );
|
wxString generateHtml( const wxString& aLine );
|
||||||
|
|
||||||
void scrollToBottom();
|
EDA_UNITS m_units;
|
||||||
|
|
||||||
///> copy of the report, stored for filtering
|
///> copy of the report, stored for filtering
|
||||||
std::vector<wxString> m_messages;
|
std::vector<wxString> m_messages;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#define _REPORTER_H_
|
#define _REPORTER_H_
|
||||||
|
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
#include <common.h>
|
||||||
#include <widgets/ui_common.h>
|
#include <widgets/ui_common.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +38,6 @@
|
||||||
|
|
||||||
class wxStatusBar;
|
class wxStatusBar;
|
||||||
class wxTextCtrl;
|
class wxTextCtrl;
|
||||||
class wxHtmlListbox;
|
|
||||||
class WX_HTML_REPORT_PANEL;
|
class WX_HTML_REPORT_PANEL;
|
||||||
class WX_INFOBAR;
|
class WX_INFOBAR;
|
||||||
|
|
||||||
|
@ -118,6 +118,11 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool HasMessage() const = 0;
|
virtual bool HasMessage() const = 0;
|
||||||
|
|
||||||
|
virtual EDA_UNITS GetUnits() const
|
||||||
|
{
|
||||||
|
return EDA_UNITS::MILLIMETRES;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~REPORTER()
|
virtual ~REPORTER()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue