Use system text and background colors in PCB calculator

wxHtmlWindow forces white background and black text. Force it back to
system settings.
This commit is contained in:
Mikolaj Wielgus 2021-10-07 01:44:27 +02:00 committed by Roberto Fernandez Bautista
parent f9c83dbc44
commit faad5ee1ce
12 changed files with 153 additions and 30 deletions

View File

@ -347,6 +347,7 @@ set( COMMON_SRCS
grid_tricks.cpp
hotkey_store.cpp
hotkeys_basic.cpp
html_window.cpp
kiface_base.cpp
kiid.cpp
kiway.cpp

55
common/html_window.cpp Normal file
View File

@ -0,0 +1,55 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2021 Mikołaj Wielgus <wielgusmikolaj@gmail.com>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <html_window.h>
#include <wx/settings.h>
HTML_WINDOW::HTML_WINDOW( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos,
const wxSize& aSize, long aStyle, const wxString& aName )
: wxHtmlWindow( aParent, aId, aPos, aSize, aStyle, aName )
{
Bind( wxEVT_SYS_COLOUR_CHANGED,
wxSysColourChangedEventHandler( HTML_WINDOW::onThemeChanged ), this );
}
bool HTML_WINDOW::SetPage( const wxString& aSource )
{
m_pageSource = aSource;
wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
wxColour fg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
return wxHtmlWindow::SetPage( "<body text=\"" + fg.GetAsString( wxC2S_HTML_SYNTAX ) + "\""
+ " bgcolor=\"" + bg.GetAsString( wxC2S_HTML_SYNTAX ) + "\">\n"
+ aSource
+ "\n</body>" );
}
void HTML_WINDOW::onThemeChanged( wxSysColourChangedEvent &aEvent )
{
SetPage( m_pageSource );
}

48
include/html_window.h Normal file
View File

@ -0,0 +1,48 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2021 Mikołaj Wielgus <wielgusmikolaj@gmail.com>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.TXT for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HTML_WINDOW_H
#define HTML_WINDOW_H
#include <wx/html/htmlwin.h>
/**
* Add dark theme support to wxHtmlWindow.
*/
class HTML_WINDOW : public wxHtmlWindow
{
public:
HTML_WINDOW( wxWindow* aParent, wxWindowID aId=wxID_ANY, const wxPoint& aPos=wxDefaultPosition,
const wxSize& aSize=wxDefaultSize, long aStyle=wxHW_DEFAULT_STYLE,
const wxString& aName="htmlWindow" );
bool SetPage( const wxString& aSource ) override;
private:
void onThemeChanged( wxSysColourChangedEvent &aEvent );
wxString m_pageSource;
};
#endif /* HTML_WINDOW_H */

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -157,7 +157,7 @@ PANEL_ATTENUATORS_BASE::PANEL_ATTENUATORS_BASE( wxWindow* parent, wxWindowID id,
bSizerMessages->Add( bSizerIndentLabel, 0, wxLEFT, 6 );
m_Attenuator_Messages = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_NO_SELECTION|wxHW_SCROLLBAR_AUTO );
m_Attenuator_Messages = new HTML_WINDOW( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_NO_SELECTION|wxHW_SCROLLBAR_AUTO );
bSizerMessages->Add( m_Attenuator_Messages, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 8 );
@ -169,7 +169,7 @@ PANEL_ATTENUATORS_BASE::PANEL_ATTENUATORS_BASE( wxWindow* parent, wxWindowID id,
wxStaticBoxSizer* sbRightSizerFormula;
sbRightSizerFormula = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Formula") ), wxVERTICAL );
m_panelAttFormula = new wxHtmlWindow( sbRightSizerFormula->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
m_panelAttFormula = new HTML_WINDOW( sbRightSizerFormula->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
sbRightSizerFormula->Add( m_panelAttFormula, 1, wxEXPAND|wxBOTTOM, 5 );

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<FileVersion major="1" minor="16" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@ -14,6 +14,7 @@
<property name="file">panel_attenuators_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">panel_attenuators_base</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Panel" expanded="1">
@ -46,6 +48,7 @@
<property name="size">500,300</property>
<property name="subclass">; ; forward_declare</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
@ -821,6 +824,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -894,6 +898,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -1546,11 +1551,11 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxEXPAND|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerMessages</property>
<property name="orient">wxVERTICAL</property>
@ -1677,7 +1682,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxHW_NO_SELECTION|wxHW_SCROLLBAR_AUTO</property>
<property name="subclass"></property>
<property name="subclass">HTML_WINDOW; html_window.h; </property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
@ -1751,7 +1756,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxHW_SCROLLBAR_AUTO</property>
<property name="subclass"></property>
<property name="subclass">HTML_WINDOW; html_window.h; </property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -10,6 +10,7 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "html_window.h"
#include <wx/string.h>
#include <wx/radiobox.h>
#include <wx/gdicmn.h>
@ -63,10 +64,10 @@ class PANEL_ATTENUATORS_BASE : public wxPanel
wxTextCtrl* m_Att_R3_Value;
wxStaticText* m_attR3Unit;
wxStaticText* m_staticTextAttMsg;
wxHtmlWindow* m_Attenuator_Messages;
wxHtmlWindow* m_panelAttFormula;
HTML_WINDOW* m_Attenuator_Messages;
HTML_WINDOW* m_panelAttFormula;
// Virtual event handlers, overide them in your derived class
// Virtual event handlers, override them in your derived class
virtual void OnAttenuatorSelection( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCalculateAttenuator( wxCommandEvent& event ) { event.Skip(); }
@ -74,6 +75,7 @@ class PANEL_ATTENUATORS_BASE : public wxPanel
public:
PANEL_ATTENUATORS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_ATTENUATORS_BASE();
};

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -183,7 +183,7 @@ PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE( wxWindow* parent, wxWindowID id, const w
wxStaticBoxSizer* sbLowerSizerEseriesHelp;
sbLowerSizerEseriesHelp = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Help") ), wxVERTICAL );
m_panelESeriesHelp = new wxHtmlWindow( sbLowerSizerEseriesHelp->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
m_panelESeriesHelp = new HTML_WINDOW( sbLowerSizerEseriesHelp->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO );
sbLowerSizerEseriesHelp->Add( m_panelESeriesHelp, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<FileVersion major="1" minor="16" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@ -14,6 +14,7 @@
<property name="file">panel_eserie_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">panel_eserie_base</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Panel" expanded="1">
@ -46,6 +48,7 @@
<property name="size">677,453</property>
<property name="subclass">; ; forward_declare</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
@ -2016,6 +2019,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -2100,11 +2104,11 @@
<property name="name">bLowerESerie</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="0">
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Help</property>
<property name="minimum_size"></property>
@ -2162,7 +2166,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxHW_SCROLLBAR_AUTO</property>
<property name="subclass"></property>
<property name="subclass">HTML_WINDOW; html_window.h; </property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -10,6 +10,7 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "html_window.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
@ -21,10 +22,10 @@
#include <wx/statline.h>
#include <wx/radiobut.h>
#include <wx/statbox.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/html/htmlwin.h>
#include <wx/panel.h>
@ -70,9 +71,9 @@ class PANEL_E_SERIE_BASE : public wxPanel
wxStaticText* m_ESeriesAltPercent1;
wxStaticLine* m_staticline7;
wxButton* m_buttonEScalculate;
wxHtmlWindow* m_panelESeriesHelp;
HTML_WINDOW* m_panelESeriesHelp;
// Virtual event handlers, overide them in your derived class
// Virtual event handlers, override them in your derived class
virtual void OnESeriesSelection( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCalculateESeries( wxCommandEvent& event ) { event.Skip(); }
@ -80,6 +81,7 @@ class PANEL_E_SERIE_BASE : public wxPanel
public:
PANEL_E_SERIE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 677,453 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_E_SERIE_BASE();
};

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -79,7 +79,7 @@ PANEL_TRACK_WIDTH_BASE::PANEL_TRACK_WIDTH_BASE( wxWindow* parent, wxWindowID id,
bSizeLeft->Add( sbSizerTW_Prms, 0, wxALL|wxEXPAND, 5 );
m_htmlWinFormulas = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_NO_SELECTION|wxHW_SCROLLBAR_AUTO );
m_htmlWinFormulas = new HTML_WINDOW( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_NO_SELECTION|wxHW_SCROLLBAR_AUTO );
bSizeLeft->Add( m_htmlWinFormulas, 1, wxEXPAND|wxALL, 8 );

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<FileVersion major="1" minor="16" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@ -14,6 +14,7 @@
<property name="file">panel_track_width_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">panel_track_width_base</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Panel" expanded="1">
@ -46,6 +48,7 @@
<property name="size">623,457</property>
<property name="subclass">; ; forward_declare</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
@ -897,7 +900,7 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxHW_NO_SELECTION|wxHW_SCROLLBAR_AUTO</property>
<property name="subclass"></property>
<property name="subclass">HTML_WINDOW; html_window.h; </property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
@ -3569,6 +3572,7 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -13,6 +13,7 @@
class UNIT_SELECTOR_LEN;
class UNIT_SELECTOR_THICKNESS;
#include "html_window.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
@ -25,10 +26,10 @@ class UNIT_SELECTOR_THICKNESS;
#include <wx/statbox.h>
#include <wx/html/htmlwin.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/button.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
@ -54,7 +55,7 @@ class PANEL_TRACK_WIDTH_BASE : public wxPanel
wxStaticText* m_staticText103;
wxTextCtrl* m_TWResistivity;
wxStaticText* m_resistivityUnits;
wxHtmlWindow* m_htmlWinFormulas;
HTML_WINDOW* m_htmlWinFormulas;
wxStaticText* m_staticTextExtWidth;
wxTextCtrl* m_ExtTrackWidthValue;
UNIT_SELECTOR_LEN* m_TW_ExtTrackWidth_choiceUnit;
@ -99,7 +100,7 @@ class PANEL_TRACK_WIDTH_BASE : public wxPanel
wxStaticText* m_staticText7911;
wxButton* m_buttonTrackWidthReset;
// Virtual event handlers, overide them in your derived class
// Virtual event handlers, override them in your derived class
virtual void OnTWCalculateFromCurrent( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTWParametersChanged( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTWCalculateFromExtWidth( wxCommandEvent& event ) { event.Skip(); }
@ -110,6 +111,7 @@ class PANEL_TRACK_WIDTH_BASE : public wxPanel
public:
PANEL_TRACK_WIDTH_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 623,457 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_TRACK_WIDTH_BASE();
};