From 26624333747c8924aa2ba803a401f01986176c5e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 9 Oct 2021 09:07:18 +0200 Subject: [PATCH] Pcb calculator panels: ensure sizer are correctly updated. On wxWidgets 3.0, SetSizeHints must be called once the panel is fully populated. On wxWidgets 3.1.5, SetSizeHints is not mandatory but can be called to ensure right sizes once the panel is fully populated. --- .../calculator_panels/panel_attenuators.cpp | 4 ++++ .../calculator_panels/panel_board_class.cpp | 3 +++ .../calculator_panels/panel_color_code.cpp | 3 +++ .../calculator_panels/panel_electrical_spacing.cpp | 3 +++ pcb_calculator/calculator_panels/panel_eserie.cpp | 14 ++++++++------ .../calculator_panels/panel_regulator.cpp | 3 +++ .../calculator_panels/panel_track_width.cpp | 3 +++ .../calculator_panels/panel_transline.cpp | 5 +++++ .../calculator_panels/panel_via_size.cpp | 3 +++ 9 files changed, 35 insertions(+), 6 deletions(-) diff --git a/pcb_calculator/calculator_panels/panel_attenuators.cpp b/pcb_calculator/calculator_panels/panel_attenuators.cpp index 5c19c381e4..644cd9817f 100644 --- a/pcb_calculator/calculator_panels/panel_attenuators.cpp +++ b/pcb_calculator/calculator_panels/panel_attenuators.cpp @@ -47,6 +47,7 @@ PANEL_ATTENUATORS::PANEL_ATTENUATORS( wxWindow* parent, wxWindowID id, m_AttenuatorList.push_back( new ATTENUATOR_BRIDGE() ); m_AttenuatorList.push_back( new ATTENUATOR_SPLITTER() ); m_CurrAttenuator = m_AttenuatorList[0]; + SetAttenuator( 0 ); // Ensure an attenuator and especially its bitmap are set m_staticTextAttMsg->SetFont( KIUI::GetInfoFont( this ).Italic() ); @@ -55,6 +56,9 @@ PANEL_ATTENUATORS::PANEL_ATTENUATORS( wxWindow* parent, wxWindowID id, m_attR1Unit->SetLabel( wxT( "Ω" ) ); m_attR2Unit->SetLabel( wxT( "Ω" ) ); m_attR3Unit->SetLabel( wxT( "Ω" ) ); + + // Needed on wxWidgets 3.0 to ensure sizers are correctly set + GetSizer()->SetSizeHints( this ); } diff --git a/pcb_calculator/calculator_panels/panel_board_class.cpp b/pcb_calculator/calculator_panels/panel_board_class.cpp index bd5b48d4bf..821d736e90 100644 --- a/pcb_calculator/calculator_panels/panel_board_class.cpp +++ b/pcb_calculator/calculator_panels/panel_board_class.cpp @@ -30,6 +30,9 @@ PANEL_BOARD_CLASS::PANEL_BOARD_CLASS( wxWindow* parent, wxWindowID id, { // Autosize the row label column to be sure label are not truncated m_gridClassesValuesDisplay->SetRowLabelSize( wxGRID_AUTOSIZE ); + + // Needed on wxWidgets 3.0 to ensure sizers are correctly set + GetSizer()->SetSizeHints( this ); } diff --git a/pcb_calculator/calculator_panels/panel_color_code.cpp b/pcb_calculator/calculator_panels/panel_color_code.cpp index 6160057e6e..d398cc8459 100644 --- a/pcb_calculator/calculator_panels/panel_color_code.cpp +++ b/pcb_calculator/calculator_panels/panel_color_code.cpp @@ -30,6 +30,9 @@ PANEL_COLOR_CODE::PANEL_COLOR_CODE( wxWindow* parent, wxWindowID id, { initColorCodePanel(); ToleranceSelection( m_rbToleranceSelection->GetSelection() ); + + // Needed on wxWidgets 3.0 to ensure sizers are correctly set + GetSizer()->SetSizeHints( this ); } diff --git a/pcb_calculator/calculator_panels/panel_electrical_spacing.cpp b/pcb_calculator/calculator_panels/panel_electrical_spacing.cpp index 033bd07df7..71cfa020e3 100644 --- a/pcb_calculator/calculator_panels/panel_electrical_spacing.cpp +++ b/pcb_calculator/calculator_panels/panel_electrical_spacing.cpp @@ -115,6 +115,9 @@ PANEL_ELECTRICAL_SPACING::PANEL_ELECTRICAL_SPACING( wxWindow* parent, wxWindowID { // Autosize the row label column to be sure label are not truncated m_gridElectricalSpacingValues->SetRowLabelSize( wxGRID_AUTOSIZE ); + + // Needed on wxWidgets 3.0 to ensure sizers are correctly set + GetSizer()->SetSizeHints( this ); } diff --git a/pcb_calculator/calculator_panels/panel_eserie.cpp b/pcb_calculator/calculator_panels/panel_eserie.cpp index c6715f4512..00c5e86cf9 100644 --- a/pcb_calculator/calculator_panels/panel_eserie.cpp +++ b/pcb_calculator/calculator_panels/panel_eserie.cpp @@ -41,6 +41,14 @@ PANEL_E_SERIE::PANEL_E_SERIE( wxWindow* parent, wxWindowID id, m_reqResUnits->SetLabel( wxT( "kΩ" ) ); m_exclude1Units->SetLabel( wxT( "kΩ" ) ); m_exclude2Units->SetLabel( wxT( "kΩ" ) ); + + // show markdown formula explanation in lower help panel + wxString msg; + ConvertMarkdown2Html( wxGetTranslation( eseries_help ), msg ); + m_panelESeriesHelp->SetPage( msg ); + + // Needed on wxWidgets 3.0 to ensure sizers are correctly set + GetSizer()->SetSizeHints( this ); } @@ -63,10 +71,4 @@ void PANEL_E_SERIE::SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg ) void PANEL_E_SERIE::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg ) { - // initialize ESeries tab at each pcb-calculator start - wxString msg; - - // show markdown formula explanation in lower help panel - ConvertMarkdown2Html( wxGetTranslation( eseries_help ), msg ); - m_panelESeriesHelp->SetPage( msg ); } diff --git a/pcb_calculator/calculator_panels/panel_regulator.cpp b/pcb_calculator/calculator_panels/panel_regulator.cpp index 034f698d8d..1bf59d0d85 100644 --- a/pcb_calculator/calculator_panels/panel_regulator.cpp +++ b/pcb_calculator/calculator_panels/panel_regulator.cpp @@ -53,6 +53,9 @@ PANEL_REGULATOR::PANEL_REGULATOR( wxWindow* parent, wxWindowID id, m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() ); SelectLastSelectedRegulator(); + + // Needed on wxWidgets 3.0 to ensure sizers are correctly set + GetSizer()->SetSizeHints( this ); } PANEL_REGULATOR::~PANEL_REGULATOR() diff --git a/pcb_calculator/calculator_panels/panel_track_width.cpp b/pcb_calculator/calculator_panels/panel_track_width.cpp index 04d4d2924d..d695319d03 100644 --- a/pcb_calculator/calculator_panels/panel_track_width.cpp +++ b/pcb_calculator/calculator_panels/panel_track_width.cpp @@ -58,6 +58,9 @@ PANEL_TRACK_WIDTH::PANEL_TRACK_WIDTH( wxWindow* parent, wxWindowID id, m_TWMode = TW_MASTER_CURRENT; m_TWNested = false; + + // Needed on wxWidgets 3.0 to ensure sizers are correctly set + GetSizer()->SetSizeHints( this ); } diff --git a/pcb_calculator/calculator_panels/panel_transline.cpp b/pcb_calculator/calculator_panels/panel_transline.cpp index 80f568cc38..52f4d73f11 100644 --- a/pcb_calculator/calculator_panels/panel_transline.cpp +++ b/pcb_calculator/calculator_panels/panel_transline.cpp @@ -90,6 +90,11 @@ void PANEL_TRANSLINE::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg ) TranslineTypeSelection( m_currTransLineType ); m_TranslineSelection->SetSelection( m_currTransLineType ); + + // Needed on wxWidgets 3.0 to ensure sizers are correctly set + // It also remove a minor cosmetic issue on wxWidgets 3.5 on MSW + // Called here after the current selected transline bitmaps are enabled/disabled + GetSizer()->SetSizeHints( this ); } diff --git a/pcb_calculator/calculator_panels/panel_via_size.cpp b/pcb_calculator/calculator_panels/panel_via_size.cpp index 1c003f3492..ddad3512da 100644 --- a/pcb_calculator/calculator_panels/panel_via_size.cpp +++ b/pcb_calculator/calculator_panels/panel_via_size.cpp @@ -67,6 +67,9 @@ PANEL_VIA_SIZE::PANEL_VIA_SIZE( wxWindow* parent, wxWindowID id, m_viaReactanceUnits->SetLabel( wxT( "Ω" ) ); m_viaBitmap->SetBitmap( KiBitmap( BITMAPS::viacalc ) ); + + // Needed on wxWidgets 3.0 to ensure sizers are correctly set + GetSizer()->SetSizeHints( this ); }