From 3aae3c6f65e068128dfe533a2bd19f43c4dc696d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 14 Sep 2021 19:26:03 +0100 Subject: [PATCH] Dark mode for a bunch of HTML dialogs. WX_HTML_REPORT_BOX WX_HTML_REPORT_PANEL HTML_MESSAGEBOX DIALOG_DISPLAY_HTML_TEXT Fixes https://gitlab.com/kicad/code/kicad/issues/9157 Fixes https://gitlab.com/kicad/code/kicad/issues/9156 --- common/CMakeLists.txt | 4 +- common/confirm.cpp | 2 +- common/dialog_about/dialog_about.cpp | 2 +- common/dialogs/dialog_configure_paths.cpp | 4 +- ....cpp => dialog_display_html_text_base.cpp} | 2 +- ....fbp => dialog_display_html_text_base.fbp} | 6 +- ...ml_messagebox.cpp => html_message_box.cpp} | 76 ++++++++++++++++--- common/dialogs/wx_html_report_box.cpp | 24 +++++- common/dialogs/wx_html_report_box.h | 2 + common/dialogs/wx_html_report_panel.cpp | 71 ++++++++--------- common/dialogs/wx_html_report_panel.h | 2 + common/footprint_info.cpp | 2 +- common/marker_base.cpp | 2 +- cvpcb/readwrite_dlgs.cpp | 2 +- eeschema/dialogs/dialog_bom.cpp | 6 +- .../dialogs/dialog_sheet_pin_properties.cpp | 2 +- .../dialog_text_and_label_properties.cpp | 2 +- eeschema/sch_edit_frame.cpp | 2 +- eeschema/sch_text.cpp | 6 +- .../symbol_editor/symbol_library_manager.cpp | 2 +- eeschema/symbol_tree_model_adapter.cpp | 2 +- eeschema/tools/ee_inspection_tool.cpp | 43 +++++++++-- gerbview/excellon_read_drill_file.cpp | 2 +- gerbview/files.cpp | 2 +- gerbview/job_file_reader.cpp | 2 +- gerbview/readgerb.cpp | 2 +- .../dialogs/dialog_display_html_text_base.h | 2 +- .../{html_messagebox.h => html_message_box.h} | 19 +++-- .../dialogs/properties_frame.cpp | 4 +- .../dialog_graphic_item_properties.cpp | 2 +- pcbnew/dialogs/dialog_netlist.cpp | 2 +- pcbnew/dialogs/dialog_pad_properties.cpp | 2 +- pcbnew/dialogs/panel_setup_rules.cpp | 6 +- pcbnew/footprint_info_impl.cpp | 2 +- pcbnew/import_gfx/dialog_import_gfx.cpp | 2 +- 35 files changed, 217 insertions(+), 98 deletions(-) rename common/dialogs/{dialog_display_info_HTML_base.cpp => dialog_display_html_text_base.cpp} (96%) rename common/dialogs/{dialog_display_info_HTML_base.fbp => dialog_display_html_text_base.fbp} (97%) rename common/dialogs/{html_messagebox.cpp => html_message_box.cpp} (65%) rename common/dialogs/dialog_display_info_HTML_base.h => include/dialogs/dialog_display_html_text_base.h (100%) rename include/dialogs/{html_messagebox.h => html_message_box.h} (88%) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 8e3e66057d..0221960800 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -158,7 +158,7 @@ set( COMMON_DLG_SRCS dialogs/dialog_color_picker_base.cpp dialogs/dialog_configure_paths.cpp dialogs/dialog_configure_paths_base.cpp - dialogs/dialog_display_info_HTML_base.cpp + dialogs/dialog_display_html_text_base.cpp dialogs/dialog_edit_library_tables.cpp dialogs/dialog_global_lib_table_config.cpp dialogs/dialog_global_lib_table_config_base.cpp @@ -186,7 +186,7 @@ set( COMMON_DLG_SRCS dialogs/eda_list_dialog_base.cpp dialogs/eda_view_switcher.cpp dialogs/eda_view_switcher_base.cpp - dialogs/html_messagebox.cpp + dialogs/html_message_box.cpp dialogs/panel_color_settings_base.cpp dialogs/panel_color_settings.cpp dialogs/panel_common_settings.cpp diff --git a/common/confirm.cpp b/common/confirm.cpp index 4ae4ec96f7..41ce809c14 100644 --- a/common/confirm.cpp +++ b/common/confirm.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include diff --git a/common/dialog_about/dialog_about.cpp b/common/dialog_about/dialog_about.cpp index cf0b133f4c..91cf106e7f 100644 --- a/common/dialog_about/dialog_about.cpp +++ b/common/dialog_about/dialog_about.cpp @@ -42,7 +42,7 @@ */ #include #include -#include +#include #include #include "dialog_about.h" diff --git a/common/dialogs/dialog_configure_paths.cpp b/common/dialogs/dialog_configure_paths.cpp index 397fe73acd..ed86ecea79 100644 --- a/common/dialogs/dialog_configure_paths.cpp +++ b/common/dialogs/dialog_configure_paths.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -621,7 +621,7 @@ void DIALOG_CONFIGURE_PATHS::OnHelp( wxCommandEvent& event ) } - m_helpDialog = new HTML_MESSAGE_BOX( nullptr, _( "Environment Variable Help" ) ); + m_helpDialog = new HTML_MESSAGE_BOX( nullptr, this, _( "Environment Variable Help" ) ); m_helpDialog->SetDialogSizeInDU( 400, 250 ); m_helpDialog->AddHTML_Text( msg ); diff --git a/common/dialogs/dialog_display_info_HTML_base.cpp b/common/dialogs/dialog_display_html_text_base.cpp similarity index 96% rename from common/dialogs/dialog_display_info_HTML_base.cpp rename to common/dialogs/dialog_display_html_text_base.cpp index d492f8af4c..503972a065 100644 --- a/common/dialogs/dialog_display_info_HTML_base.cpp +++ b/common/dialogs/dialog_display_html_text_base.cpp @@ -5,7 +5,7 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "dialog_display_info_HTML_base.h" +#include "dialogs/dialog_display_html_text_base.h" /////////////////////////////////////////////////////////////////////////// diff --git a/common/dialogs/dialog_display_info_HTML_base.fbp b/common/dialogs/dialog_display_html_text_base.fbp similarity index 97% rename from common/dialogs/dialog_display_info_HTML_base.fbp rename to common/dialogs/dialog_display_html_text_base.fbp index da400200d1..afa5ef6bdc 100644 --- a/common/dialogs/dialog_display_info_HTML_base.fbp +++ b/common/dialogs/dialog_display_html_text_base.fbp @@ -11,12 +11,12 @@ res UTF-8 connect - dialog_display_info_HTML_base + dialog_display_html_text_base 1000 none 1 - dialog_display_info_HTML + dialog_display_html_text_base . @@ -101,7 +101,7 @@ 1 - public + protected 1 Resizable diff --git a/common/dialogs/html_messagebox.cpp b/common/dialogs/html_message_box.cpp similarity index 65% rename from common/dialogs/html_messagebox.cpp rename to common/dialogs/html_message_box.cpp index 7080555b59..9c21ab7f1c 100644 --- a/common/dialogs/html_messagebox.cpp +++ b/common/dialogs/html_message_box.cpp @@ -24,13 +24,33 @@ #include #include +#include #include -#include +#include + + +HTML_MESSAGE_BOX::HTML_MESSAGE_BOX( wxWindow* aParent, wxWindow* aHost, const wxString& aTitle ) : + DIALOG_DISPLAY_HTML_TEXT_BASE( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize ), + m_host( aHost ) +{ + m_htmlWindow->SetLayoutDirection( wxLayout_LeftToRight ); + ListClear(); + + Center(); + + m_sdbSizer1OK->SetDefault(); + + reload(); + + Bind( wxEVT_SYS_COLOUR_CHANGED, + wxSysColourChangedEventHandler( HTML_MESSAGE_BOX::onThemeChanged ), this ); +} HTML_MESSAGE_BOX::HTML_MESSAGE_BOX( wxWindow* aParent, const wxString& aTitle, const wxPoint& aPosition, const wxSize& aSize ) : - DIALOG_DISPLAY_HTML_TEXT_BASE( aParent, wxID_ANY, aTitle, aPosition, aSize ) + DIALOG_DISPLAY_HTML_TEXT_BASE( nullptr, wxID_ANY, aTitle, aPosition, aSize ), + m_host( aParent ) { m_htmlWindow->SetLayoutDirection( wxLayout_LeftToRight ); ListClear(); @@ -42,6 +62,11 @@ HTML_MESSAGE_BOX::HTML_MESSAGE_BOX( wxWindow* aParent, const wxString& aTitle, Center(); m_sdbSizer1OK->SetDefault(); + + reload(); + + Bind( wxEVT_SYS_COLOUR_CHANGED, + wxSysColourChangedEventHandler( HTML_MESSAGE_BOX::onThemeChanged ), this ); } @@ -53,9 +78,37 @@ HTML_MESSAGE_BOX::~HTML_MESSAGE_BOX() } +void HTML_MESSAGE_BOX::reload() +{ + // Handle light/dark mode colors... + + wxTextCtrl dummy( m_host, wxID_ANY ); + wxColour foreground = dummy.GetForegroundColour(); + wxColour background = dummy.GetBackgroundColour(); + + m_htmlWindow->SetPage( wxString::Format( wxT( "" + " " + " %s" + " " + "" ), + background.GetAsString( wxC2S_HTML_SYNTAX ), + foreground.GetAsString( wxC2S_HTML_SYNTAX ), + m_source ) ); +} + + +void HTML_MESSAGE_BOX::onThemeChanged( wxSysColourChangedEvent &aEvent ) +{ + reload(); + + aEvent.Skip(); +} + + void HTML_MESSAGE_BOX::ListClear() { - m_htmlWindow->SetPage( wxEmptyString ); + m_source.clear(); + reload(); } @@ -74,7 +127,8 @@ void HTML_MESSAGE_BOX::ListSet( const wxString& aList ) msg += wxT( "" ); - m_htmlWindow->AppendToPage( msg ); + m_source += msg; + reload(); } @@ -90,27 +144,31 @@ void HTML_MESSAGE_BOX::ListSet( const wxArrayString& aList ) msg += wxT( "" ); - m_htmlWindow->AppendToPage( msg ); + m_source += msg; + reload(); } void HTML_MESSAGE_BOX::MessageSet( const wxString& message ) { - wxString message_value = wxString::Format( - wxT( "%s
" ), message ); + wxString message_value = wxString::Format( wxT( "%s
" ), message ); - m_htmlWindow->AppendToPage( message_value ); + m_source += message_value; + reload(); } void HTML_MESSAGE_BOX::AddHTML_Text( const wxString& message ) { - m_htmlWindow->AppendToPage( message ); + m_source += message; + reload(); } void HTML_MESSAGE_BOX::ShowModeless() { + reload(); + m_sdbSizer1->Show( false ); Layout(); diff --git a/common/dialogs/wx_html_report_box.cpp b/common/dialogs/wx_html_report_box.cpp index 4c00260f7d..2f9ba2d95b 100644 --- a/common/dialogs/wx_html_report_box.cpp +++ b/common/dialogs/wx_html_report_box.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "wx_html_report_box.h" @@ -30,6 +31,18 @@ WX_HTML_REPORT_BOX::WX_HTML_REPORT_BOX( wxWindow* parent, wxWindowID id, const w m_units( EDA_UNITS::MILLIMETRES ), m_immediateMode( false ) { + Flush(); + + Bind( wxEVT_SYS_COLOUR_CHANGED, + wxSysColourChangedEventHandler( WX_HTML_REPORT_BOX::onThemeChanged ), this ); +} + + +void WX_HTML_REPORT_BOX::onThemeChanged( wxSysColourChangedEvent &aEvent ) +{ + Flush(); + + aEvent.Skip(); } @@ -62,16 +75,19 @@ void WX_HTML_REPORT_BOX::Flush() wxString WX_HTML_REPORT_BOX::addHeader( const wxString& aBody ) { - wxColour bgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ); - wxColour fgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ); + // Handle light/dark mode colors... + + wxTextCtrl dummy( GetParent(), wxID_ANY ); + wxColour foreground = dummy.GetForegroundColour(); + wxColour background = dummy.GetBackgroundColour(); return wxString::Format( wxT( "" " " " %s" " " "" ), - bgcolor.GetAsString( wxC2S_HTML_SYNTAX ), - fgcolor.GetAsString( wxC2S_HTML_SYNTAX ), + background.GetAsString( wxC2S_HTML_SYNTAX ), + foreground.GetAsString( wxC2S_HTML_SYNTAX ), aBody ); } diff --git a/common/dialogs/wx_html_report_box.h b/common/dialogs/wx_html_report_box.h index d3644c1aac..9d17e99a22 100644 --- a/common/dialogs/wx_html_report_box.h +++ b/common/dialogs/wx_html_report_box.h @@ -60,6 +60,8 @@ public: void Clear(); private: + void onThemeChanged( wxSysColourChangedEvent &aEvent ); + wxString addHeader( const wxString& aBody ); wxString generateHtml( const wxString& aLine ); diff --git a/common/dialogs/wx_html_report_panel.cpp b/common/dialogs/wx_html_report_panel.cpp index aed3524bd1..1b66b110b8 100644 --- a/common/dialogs/wx_html_report_panel.cpp +++ b/common/dialogs/wx_html_report_panel.cpp @@ -32,13 +32,10 @@ #include #include #include +#include - -WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style ) : +WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos, + const wxSize& size, long style ) : WX_HTML_REPORT_PANEL_BASE( parent, id, pos, size, style ), m_reporter( this ), m_severities( -1 ), @@ -46,10 +43,14 @@ WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL( wxWindow* parent, { syncCheckboxes(); m_htmlView->SetFont( KIUI::GetInfoFont( m_htmlView ) ); - m_htmlView->SetPage( addHeader( "" ) ); + Flush(); Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( WX_HTML_REPORT_PANEL::onMenuEvent ), nullptr, this ); + + m_htmlView->Bind( wxEVT_SYS_COLOUR_CHANGED, + wxSysColourChangedEventHandler( WX_HTML_REPORT_PANEL::onThemeChanged ), + this ); } @@ -58,6 +59,14 @@ WX_HTML_REPORT_PANEL::~WX_HTML_REPORT_PANEL() } +void WX_HTML_REPORT_PANEL::onThemeChanged( wxSysColourChangedEvent &aEvent ) +{ + Flush(); + + aEvent.Skip(); +} + + void WX_HTML_REPORT_PANEL::MsgPanelSetMinSize( const wxSize& aMinSize ) { m_fgSizer->SetMinSize( aMinSize ); @@ -150,12 +159,19 @@ void WX_HTML_REPORT_PANEL::updateBadges() wxString WX_HTML_REPORT_PANEL::addHeader( const wxString& aBody ) { - wxColour bgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ); - wxColour fgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT ); + // Handle light/dark mode colors... - return wxString::Format( wxT( "%s" ), - bgcolor.GetAsString( wxC2S_HTML_SYNTAX ), - fgcolor.GetAsString( wxC2S_HTML_SYNTAX ), + wxTextCtrl dummy( GetParent(), wxID_ANY ); + wxColour foreground = dummy.GetForegroundColour(); + wxColour background = dummy.GetBackgroundColour(); + + return wxString::Format( wxT( "" + " " + " %s" + " " + "" ), + background.GetAsString( wxC2S_HTML_SYNTAX ), + foreground.GetAsString( wxC2S_HTML_SYNTAX ), aBody ); } @@ -211,14 +227,10 @@ wxString WX_HTML_REPORT_PANEL::generatePlainText( const REPORT_LINE& aLine ) { switch( aLine.severity ) { - case RPT_SEVERITY_ERROR: - return _( "Error:" ) + wxS( " " )+ aLine.message + wxT( "\n" ); - case RPT_SEVERITY_WARNING: - return _( "Warning:" ) + wxS( " " )+ aLine.message + wxT( "\n" ); - case RPT_SEVERITY_INFO: - return _( "Info:" ) + wxS( " " )+ aLine.message + wxT( "\n" ); - default: - return aLine.message + wxT( "\n" ); + case RPT_SEVERITY_ERROR: return _( "Error:" ) + wxS( " " ) + aLine.message + wxT( "\n" ); + case RPT_SEVERITY_WARNING: return _( "Warning:" ) + wxS( " " ) + aLine.message + wxT( "\n" ); + case RPT_SEVERITY_INFO: return _( "Info:" ) + wxS( " " ) + aLine.message + wxT( "\n" ); + default: return aLine.message + wxT( "\n" ); } } @@ -420,20 +432,9 @@ void WX_HTML_REPORT_PANEL::SetShowSeverity( SEVERITY aSeverity, bool aValue ) { switch( aSeverity ) { - case RPT_SEVERITY_INFO: - m_checkBoxShowInfos->SetValue( aValue ); - break; - - case RPT_SEVERITY_ACTION: - m_checkBoxShowActions->SetValue( aValue ); - break; - - case RPT_SEVERITY_WARNING: - m_checkBoxShowWarnings->SetValue( aValue ); - break; - - default: - m_checkBoxShowErrors->SetValue( aValue ); - break; + case RPT_SEVERITY_INFO: m_checkBoxShowInfos->SetValue( aValue ); break; + case RPT_SEVERITY_ACTION: m_checkBoxShowActions->SetValue( aValue ); break; + case RPT_SEVERITY_WARNING: m_checkBoxShowWarnings->SetValue( aValue ); break; + default: m_checkBoxShowErrors->SetValue( aValue ); break; } } diff --git a/common/dialogs/wx_html_report_panel.h b/common/dialogs/wx_html_report_panel.h index 4eb7a356fd..e4c7b3c3d6 100644 --- a/common/dialogs/wx_html_report_panel.h +++ b/common/dialogs/wx_html_report_panel.h @@ -121,6 +121,8 @@ private: void onBtnSaveToFile( wxCommandEvent& event ) override; + void onThemeChanged( wxSysColourChangedEvent &aEvent ); + private: WX_HTML_PANEL_REPORTER m_reporter; diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index 7b1884843a..781f579f48 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include diff --git a/common/marker_base.cpp b/common/marker_base.cpp index 22f5406bee..c1cab42bb8 100644 --- a/common/marker_base.cpp +++ b/common/marker_base.cpp @@ -35,7 +35,7 @@ #include #include #include -#include "dialog_display_info_HTML_base.h" +#include "dialogs/dialog_display_html_text_base.h" /* The graphic shape of markers is a polygon. diff --git a/cvpcb/readwrite_dlgs.cpp b/cvpcb/readwrite_dlgs.cpp index 7e85023d76..62c323c4de 100644 --- a/cvpcb/readwrite_dlgs.cpp +++ b/cvpcb/readwrite_dlgs.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index 74a51b6875..642bc91c63 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include // for _HKI definition used in dialog_bom_help_md.h #include #include @@ -458,13 +458,13 @@ void DIALOG_BOM::OnHelp( wxCommandEvent& event ) return; } - m_helpWindow = new HTML_MESSAGE_BOX( nullptr, _( "Bill of Material Generation Help" ) ); + m_helpWindow = new HTML_MESSAGE_BOX( nullptr, this, _( "Bill of Material Generation Help" ) ); m_helpWindow->SetDialogSizeInDU( 500, 350 ); wxString html_txt; ConvertMarkdown2Html( wxGetTranslation( s_bomHelpInfo ), html_txt ); - m_helpWindow->m_htmlWindow->AppendToPage( html_txt ); + m_helpWindow->AddHTML_Text( html_txt ); m_helpWindow->ShowModeless(); } diff --git a/eeschema/dialogs/dialog_sheet_pin_properties.cpp b/eeschema/dialogs/dialog_sheet_pin_properties.cpp index 9ebb0b0206..c1e824ec07 100644 --- a/eeschema/dialogs/dialog_sheet_pin_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_pin_properties.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include diff --git a/eeschema/dialogs/dialog_text_and_label_properties.cpp b/eeschema/dialogs/dialog_text_and_label_properties.cpp index a5b9bb79cd..9eb9b96985 100644 --- a/eeschema/dialogs/dialog_text_and_label_properties.cpp +++ b/eeschema/dialogs/dialog_text_and_label_properties.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 425747ea99..a244e00815 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index bd27d14f4b..9e9a31cf52 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include @@ -1728,7 +1728,7 @@ HTML_MESSAGE_BOX* SCH_TEXT::ShowSyntaxHelp( wxWindow* aParentWindow ) #include "sch_text_help_md.h" ; - HTML_MESSAGE_BOX* dlg = new HTML_MESSAGE_BOX( nullptr, _( "Syntax Help" ) ); + HTML_MESSAGE_BOX* dlg = new HTML_MESSAGE_BOX( nullptr, aParentWindow, _( "Syntax Help" ) ); wxSize sz( 320, 320 ); dlg->SetMinSize( dlg->ConvertDialogToPixels( sz ) ); @@ -1736,7 +1736,7 @@ HTML_MESSAGE_BOX* SCH_TEXT::ShowSyntaxHelp( wxWindow* aParentWindow ) wxString html_txt; ConvertMarkdown2Html( wxGetTranslation( msg ), html_txt ); - dlg->m_htmlWindow->AppendToPage( html_txt ); + dlg->AddHTML_Text( html_txt ); dlg->ShowModeless(); return dlg; diff --git a/eeschema/symbol_editor/symbol_library_manager.cpp b/eeschema/symbol_editor/symbol_library_manager.cpp index 9690dcce39..8788170808 100644 --- a/eeschema/symbol_editor/symbol_library_manager.cpp +++ b/eeschema/symbol_editor/symbol_library_manager.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/eeschema/symbol_tree_model_adapter.cpp b/eeschema/symbol_tree_model_adapter.cpp index 5d47d124be..4f45873e54 100644 --- a/eeschema/symbol_tree_model_adapter.cpp +++ b/eeschema/symbol_tree_model_adapter.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index 3aaf79835d..55f6946104 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -39,11 +39,42 @@ #include #include #include -#include +#include #include #include // for KiROUND +class DIALOG_DISPLAY_HTML_TEXT : public DIALOG_DISPLAY_HTML_TEXT_BASE +{ +public: + DIALOG_DISPLAY_HTML_TEXT( wxWindow* aParent, wxWindowID aId, const wxString& aTitle, + const wxPoint& aPos, const wxSize& aSize, long aStyle = 0 ) : + DIALOG_DISPLAY_HTML_TEXT_BASE( aParent, aId, aTitle, aPos, aSize, aStyle ) + { } + + ~DIALOG_DISPLAY_HTML_TEXT() + { } + + void SetPage( const wxString& message ) + { + // Handle light/dark mode colors... + + wxTextCtrl dummy( GetParent(), wxID_ANY ); + wxColour foreground = dummy.GetForegroundColour(); + wxColour background = dummy.GetBackgroundColour(); + + m_htmlWindow->SetPage( wxString::Format( wxT( "" + " " + " %s" + " " + "" ), + background.GetAsString( wxC2S_HTML_SYNTAX ), + foreground.GetAsString( wxC2S_HTML_SYNTAX ), + message ) ); + } +}; + + EE_INSPECTION_TOOL::EE_INSPECTION_TOOL() : EE_TOOL_BASE( "eeschema.InspectionTool" ), m_ercDialog( nullptr ) @@ -443,15 +474,15 @@ int EE_INSPECTION_TOOL::CheckSymbol( const TOOL_EVENT& aEvent ) bgcolor.GetAsString( wxC2S_HTML_SYNTAX ), fgcolor.GetAsString( wxC2S_HTML_SYNTAX ) ); - for( auto& msgPart : messages ) - outmsg += msgPart; + for( const wxString& msg : messages ) + outmsg += msg; outmsg += ""; - DIALOG_DISPLAY_HTML_TEXT_BASE error_display( m_frame, wxID_ANY, _( "Symbol Warnings" ), - wxDefaultPosition, wxSize( 700, 350 ) ); + DIALOG_DISPLAY_HTML_TEXT error_display( m_frame, wxID_ANY, _( "Symbol Warnings" ), + wxDefaultPosition, wxSize( 700, 350 ) ); - error_display.m_htmlWindow->SetPage( outmsg ); + error_display.SetPage( outmsg ); error_display.ShowModal(); } diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index f9f48a1070..2844e58acc 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -79,7 +79,7 @@ #include -#include +#include // A helper function to calculate the arc center of an arc // known by 2 end points, the radius, and the angle direction (CW or CCW) diff --git a/gerbview/files.cpp b/gerbview/files.cpp index ce9039a403..5652dcfd6a 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/gerbview/job_file_reader.cpp b/gerbview/job_file_reader.cpp index 9a624ff883..2c2baafb0d 100644 --- a/gerbview/job_file_reader.cpp +++ b/gerbview/job_file_reader.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include diff --git a/gerbview/readgerb.cpp b/gerbview/readgerb.cpp index 6137b7cce4..94b157e8a8 100644 --- a/gerbview/readgerb.cpp +++ b/gerbview/readgerb.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include diff --git a/common/dialogs/dialog_display_info_HTML_base.h b/include/dialogs/dialog_display_html_text_base.h similarity index 100% rename from common/dialogs/dialog_display_info_HTML_base.h rename to include/dialogs/dialog_display_html_text_base.h index 61a4f891c3..bdcce47325 100644 --- a/common/dialogs/dialog_display_info_HTML_base.h +++ b/include/dialogs/dialog_display_html_text_base.h @@ -32,6 +32,7 @@ class DIALOG_DISPLAY_HTML_TEXT_BASE : public DIALOG_SHIM private: protected: + wxHtmlWindow* m_htmlWindow; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; @@ -40,7 +41,6 @@ class DIALOG_DISPLAY_HTML_TEXT_BASE : public DIALOG_SHIM public: - wxHtmlWindow* m_htmlWindow; DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_DISPLAY_HTML_TEXT_BASE(); diff --git a/include/dialogs/html_messagebox.h b/include/dialogs/html_message_box.h similarity index 88% rename from include/dialogs/html_messagebox.h rename to include/dialogs/html_message_box.h index 1a50914a71..1cf20db088 100644 --- a/include/dialogs/html_messagebox.h +++ b/include/dialogs/html_message_box.h @@ -22,11 +22,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef _html_messagebox_ -#define _html_messagebox_ +#ifndef HTML_MESSAGE_BOX_H +#define HTML_MESSAGE_BOX_H - -#include <../common/dialogs/dialog_display_info_HTML_base.h> +#include class HTML_MESSAGE_BOX : public DIALOG_DISPLAY_HTML_TEXT_BASE @@ -35,6 +34,9 @@ public: HTML_MESSAGE_BOX( wxWindow* aParent, const wxString& aTitle = wxEmptyString, const wxPoint& aPosition = wxDefaultPosition, const wxSize& aSize = wxDefaultSize ); + + HTML_MESSAGE_BOX( wxWindow* aParent, wxWindow* aHost, const wxString& aTitle ); + ~HTML_MESSAGE_BOX() override; /** @@ -84,7 +86,14 @@ public: void ShowModeless(); protected: + void reload(); + + void onThemeChanged( wxSysColourChangedEvent &aEvent ); virtual void OnCharHook( wxKeyEvent& aEvt ) override; + +private: + wxWindow* m_host; + wxString m_source; }; -#endif // _html_messagebox_ +#endif // HTML_MESSAGE_BOX_H diff --git a/pagelayout_editor/dialogs/properties_frame.cpp b/pagelayout_editor/dialogs/properties_frame.cpp index 9f2fc24b6e..4d6a8e1950 100644 --- a/pagelayout_editor/dialogs/properties_frame.cpp +++ b/pagelayout_editor/dialogs/properties_frame.cpp @@ -35,7 +35,7 @@ #include "pl_editor_frame.h" #include "tools/pl_selection_tool.h" -#include +#include PROPERTIES_FRAME::PROPERTIES_FRAME( PL_EDITOR_FRAME* aParent ) : @@ -563,7 +563,7 @@ void PROPERTIES_FRAME::onHelp( wxCommandEvent& aEvent ) message = "KICAD_VERSION\n"; message << "# " << _( "(sheet number)" ) << "\n"; message << "## " << _( "(sheet count)" ) << "\n"; - message << "COMMENT1 … COMMENT9\n"; + message << "COMMENT1 � COMMENT9\n"; message << "COMPANY\n"; message << "FILENAME\n"; message << "ISSUE_DATE\n"; diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index f44ca5aab0..f523b33d83 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/pcbnew/dialogs/dialog_netlist.cpp b/pcbnew/dialogs/dialog_netlist.cpp index 469f2ca5b9..ea7e3d1ae0 100644 --- a/pcbnew/dialogs/dialog_netlist.cpp +++ b/pcbnew/dialogs/dialog_netlist.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index a2ceacad73..68a4963bb0 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/pcbnew/dialogs/panel_setup_rules.cpp b/pcbnew/dialogs/panel_setup_rules.cpp index 21169d4ab2..5fcb2d90fe 100644 --- a/pcbnew/dialogs/panel_setup_rules.cpp +++ b/pcbnew/dialogs/panel_setup_rules.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -468,12 +468,12 @@ void PANEL_SETUP_RULES::OnSyntaxHelp( wxHyperlinkEvent& aEvent ) msg.Replace( "Ctrl+", "Cmd+" ); #endif - m_helpWindow = new HTML_MESSAGE_BOX( nullptr, _( "Syntax Help" ) ); + m_helpWindow = new HTML_MESSAGE_BOX( nullptr, this, _( "Syntax Help" ) ); m_helpWindow->SetDialogSizeInDU( 320, 320 ); wxString html_txt; ConvertMarkdown2Html( wxGetTranslation( msg ), html_txt ); - m_helpWindow->m_htmlWindow->AppendToPage( html_txt ); + m_helpWindow->AddHTML_Text( html_txt ); m_helpWindow->ShowModeless(); } diff --git a/pcbnew/footprint_info_impl.cpp b/pcbnew/footprint_info_impl.cpp index f3e9fef433..1cbaa96b74 100644 --- a/pcbnew/footprint_info_impl.cpp +++ b/pcbnew/footprint_info_impl.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/pcbnew/import_gfx/dialog_import_gfx.cpp b/pcbnew/import_gfx/dialog_import_gfx.cpp index 4b87a8b08d..08b35e047a 100644 --- a/pcbnew/import_gfx/dialog_import_gfx.cpp +++ b/pcbnew/import_gfx/dialog_import_gfx.cpp @@ -22,7 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include "dialog_import_gfx.h" #include