diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 0beeab427d..808c7caf53 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -328,7 +328,6 @@ set( COMMON_SRCS eda_item.cpp eda_pattern_match.cpp eda_rect.cpp - eda_size_ctrl.cpp eda_units.cpp env_paths.cpp env_vars.cpp diff --git a/common/dialogs/eda_list_dialog.cpp b/common/dialogs/eda_list_dialog.cpp index 1e9137badd..9c4e578f52 100644 --- a/common/dialogs/eda_list_dialog.cpp +++ b/common/dialogs/eda_list_dialog.cpp @@ -23,7 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <dialog_helpers.h> +#include <eda_list_dialog.h> #include <eda_draw_frame.h> #include <string_utils.h> #include <macros.h> diff --git a/common/eda_size_ctrl.cpp b/common/eda_size_ctrl.cpp deleted file mode 100644 index 2e1e897f5f..0000000000 --- a/common/eda_size_ctrl.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2018 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 <eda_base_frame.h> -#include <dialog_helpers.h> -#include <base_units.h> - - -/********************************************************/ -/* Class to display and edit a coordinated INCHES or MM */ -/********************************************************/ -EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, const wxPoint& aPos, - EDA_UNITS user_unit, wxBoxSizer* BoxSizer ) -{ - m_UserUnit = user_unit; - - m_TextX = new wxStaticText( parent, -1, title + wxS( " " ) + _( "X:" ) ); - BoxSizer->Add( m_TextX, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); - - m_FramePosX = new wxTextCtrl( parent, -1, wxEmptyString, wxDefaultPosition ); - BoxSizer->Add( m_FramePosX, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - - m_TextY = new wxStaticText( parent, -1, title + wxS( " " ) + _( "Y:" ) ); - BoxSizer->Add( m_TextY, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); - - m_FramePosY = new wxTextCtrl( parent, -1, wxEmptyString ); - BoxSizer->Add( m_FramePosY, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); - - SetValue( aPos.x, aPos.y ); -} - - -EDA_POSITION_CTRL::~EDA_POSITION_CTRL() -{ - delete m_TextX; - delete m_TextY; - delete m_FramePosX; - delete m_FramePosY; -} - - -/* Returns (in internal units) to coordinate between (in user units) - */ -wxPoint EDA_POSITION_CTRL::GetValue() const -{ - return wxPoint( ValueFromString( m_UserUnit, m_FramePosX->GetValue() ), - ValueFromString( m_UserUnit, m_FramePosY->GetValue() ) ); -} - - -void EDA_POSITION_CTRL::Enable( bool x_win_on, bool y_win_on ) -{ - m_FramePosX->Enable( x_win_on ); - m_FramePosY->Enable( y_win_on ); -} - - -void EDA_POSITION_CTRL::SetValue( int x_value, int y_value ) -{ - m_FramePosX->SetValue( StringFromValue( m_UserUnit, x_value ) ); - m_FramePosY->SetValue( StringFromValue( m_UserUnit, y_value ) ); -} - - -/*******************/ -/* EDA_SIZE_CTRL */ -/*******************/ -EDA_SIZE_CTRL::EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, const wxSize& aSize, - EDA_UNITS aUnit, wxBoxSizer* aBoxSizer ) - : EDA_POSITION_CTRL( parent, title, wxPoint( aSize.x, aSize.y ), aUnit, aBoxSizer ) -{ -} - - -wxSize EDA_SIZE_CTRL::GetValue() const -{ - wxPoint pos = EDA_POSITION_CTRL::GetValue(); - - return wxSize( pos.x, pos.y ); -} - - diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index ac96b3df2f..74a51b6875 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -32,7 +32,7 @@ #include <bom_plugins.h> #include <confirm.h> #include <dialog_bom_base.h> -#include <dialog_helpers.h> +#include <string_utils.h> #include <eeschema_settings.h> #include <gestfich.h> #include <dialogs/html_messagebox.h> diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 86abff0418..e3e6e091ac 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -46,7 +46,6 @@ #include <project/project_file.h> #include <project/net_settings.h> #include <core/mirror.h> -#include <dialog_helpers.h> #include <trigo.h> using KIGFX::SCH_RENDER_SETTINGS; diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index 5ec3d538cd..c4e06e877b 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -39,7 +39,7 @@ #include <sch_plugins/legacy/sch_legacy_plugin.h> #include <sch_plugins/kicad/sch_sexpr_plugin.h> #include <dialogs/dialog_lib_new_symbol.h> -#include <dialog_helpers.h> +#include <eda_list_dialog.h> #include <wx/clipbrd.h> #include <wx/filedlg.h> #include <wx/log.h> diff --git a/eeschema/symbol_editor/toolbars_symbol_editor.cpp b/eeschema/symbol_editor/toolbars_symbol_editor.cpp index 4e995c1156..f734318402 100644 --- a/eeschema/symbol_editor/toolbars_symbol_editor.cpp +++ b/eeschema/symbol_editor/toolbars_symbol_editor.cpp @@ -26,7 +26,6 @@ #include <eeschema_id.h> #include <symbol_edit_frame.h> #include <sch_painter.h> -#include <dialog_helpers.h> #include <bitmaps.h> #include <symbol_library_manager.h> #include <tool/action_toolbar.h> diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index 880aed18fd..4d7cf89d64 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -26,7 +26,6 @@ #include <bitmaps.h> #include <symbol_library.h> #include <confirm.h> -#include <dialog_helpers.h> #include <dialog_choose_symbol.h> #include <eeschema_id.h> #include <eeschema_settings.h> diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index fb3d65bac0..0f3f54bdf0 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -60,7 +60,7 @@ #include <tools/sch_editor_control.h> #include <drawing_sheet/ds_proxy_undo_item.h> #include <dialog_update_from_pcb.h> -#include <dialog_helpers.h> +#include <eda_list_dialog.h> int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent ) diff --git a/gerbview/events_called_functions.cpp b/gerbview/events_called_functions.cpp index 908efb08a1..3416781ab1 100644 --- a/gerbview/events_called_functions.cpp +++ b/gerbview/events_called_functions.cpp @@ -27,7 +27,6 @@ #include <gerbview_id.h> #include <gerber_file_image.h> #include <gerber_file_image_list.h> -#include <dialog_helpers.h> #include <gal/graphics_abstraction_layer.h> #include <tool/tool_manager.h> #include <tool/selection.h> diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index f6cf92c522..3dc43f0b32 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -19,15 +19,16 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <wx/wupdlock.h> +#include <wx/stattext.h> + #include <gerbview.h> #include <gerbview_frame.h> #include <bitmaps.h> #include <gerbview_id.h> #include <gerber_file_image.h> #include <gerber_file_image_list.h> -#include <dialog_helpers.h> #include <string_utils.h> -#include <wx/wupdlock.h> #include <tool/actions.h> #include <tool/action_toolbar.h> #include <tools/gerbview_actions.h> diff --git a/include/dialog_helpers.h b/include/eda_list_dialog.h similarity index 68% rename from include/dialog_helpers.h rename to include/eda_list_dialog.h index 6f8f9218f7..175f5de96a 100644 --- a/include/dialog_helpers.h +++ b/include/eda_list_dialog.h @@ -22,20 +22,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file dialog_helpers.h - * @brief Helper dialog and control classes. - * @note Due to use of wxFormBuilder to create dialogs many of them should be removed. - */ - -#ifndef DIALOG_HELPERS_H_ -#define DIALOG_HELPERS_H_ +#ifndef EDA_LIST_DIALOG_H +#define EDA_LIST_DIALOG_H #include <../common/dialogs/eda_list_dialog_base.h> #include <eda_units.h> -void ConvertMarkdown2Html( const wxString& aMarkdownInput, wxString& aHtmlOutput ); class EDA_DRAW_FRAME; @@ -90,45 +83,4 @@ private: }; -/** - * Object to edit/enter a coordinate (pair of values) ( INCHES or MM ) in dialog boxes. - */ -class EDA_POSITION_CTRL -{ -public: - EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, const wxPoint& pos_to_edit, - EDA_UNITS user_unit, wxBoxSizer* BoxSizer ); - - ~EDA_POSITION_CTRL(); - - void Enable( bool x_win_on, bool y_win_on ); - void SetValue( int x_value, int y_value ); - wxPoint GetValue() const; - - EDA_UNITS m_UserUnit; - - wxTextCtrl* m_FramePosX; - wxTextCtrl* m_FramePosY; - -private: - wxStaticText* m_TextX; - wxStaticText* m_TextY; -}; - - -/** - * Object to edit/enter a size (pair of values for X and Y size ( INCHES or MM ) in dialog boxes. - */ -class EDA_SIZE_CTRL : public EDA_POSITION_CTRL -{ -public: - EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, const wxSize& size_to_edit, - EDA_UNITS user_unit, wxBoxSizer* BoxSizer ); - - ~EDA_SIZE_CTRL() { } - - wxSize GetValue() const; -}; - - -#endif // DIALOG_HELPERS_H_ +#endif // EDA_LIST_DIALOG_H diff --git a/include/string_utils.h b/include/string_utils.h index 227efad3c1..3f55c18291 100644 --- a/include/string_utils.h +++ b/include/string_utils.h @@ -32,6 +32,8 @@ #include <wx/filename.h> +void ConvertMarkdown2Html( const wxString& aMarkdownInput, wxString& aHtmlOutput ); + /** * Convert the old `~...~` overbar notation to the new `~{...}` one. */ diff --git a/pagelayout_editor/dialogs/dialogs_for_printing.cpp b/pagelayout_editor/dialogs/dialogs_for_printing.cpp index c5dd3719f5..93f010f007 100644 --- a/pagelayout_editor/dialogs/dialogs_for_printing.cpp +++ b/pagelayout_editor/dialogs/dialogs_for_printing.cpp @@ -29,10 +29,7 @@ */ #include <base_units.h> -#include <dialog_helpers.h> -#include <eda_item.h> #include <gr_basic.h> -#include <drawing_sheet/ds_draw_item.h> #include <drawing_sheet/ds_data_item.h> #include <drawing_sheet/ds_data_model.h> #include <drawing_sheet/ds_painter.h> diff --git a/pcb_calculator/attenuators.cpp b/pcb_calculator/attenuators.cpp index 06c2a70bfa..fdee6e62a0 100644 --- a/pcb_calculator/attenuators.cpp +++ b/pcb_calculator/attenuators.cpp @@ -26,7 +26,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <dialog_helpers.h> +#include <string_utils.h> #include "pcb_calculator_frame.h" diff --git a/pcb_calculator/eserie.cpp b/pcb_calculator/eserie.cpp index e06cdf85c3..2510d9b244 100644 --- a/pcb_calculator/eserie.cpp +++ b/pcb_calculator/eserie.cpp @@ -19,12 +19,9 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <vector> #include <array> -#include <iostream> -#include <string> -#include <dialog_helpers.h> +#include <string_utils.h> #include "class_regulator_data.h" #include "pcb_calculator_frame.h" diff --git a/pcb_calculator/tracks_width_versus_current.cpp b/pcb_calculator/tracks_width_versus_current.cpp index cbe439784a..ef2058aaab 100644 --- a/pcb_calculator/tracks_width_versus_current.cpp +++ b/pcb_calculator/tracks_width_versus_current.cpp @@ -27,9 +27,8 @@ #include <cassert> #include <cmath> #include <kiface_i.h> -#include <dialog_helpers.h> -#include "attenuators/attenuator_classes.h" +#include <string_utils.h> #include "class_regulator_data.h" #include "pcb_calculator_frame.h" #include "pcb_calculator_settings.h" diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.cpp b/pcbnew/board_stackup_manager/panel_board_stackup.cpp index d8f954c96c..148762e92d 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/panel_board_stackup.cpp @@ -47,7 +47,7 @@ #include <wx/textdlg.h> #include <locale_io.h> -#include <dialog_helpers.h> +#include <eda_list_dialog.h> // Some wx widget ID to know what widget has fired a event: diff --git a/pcbnew/dialogs/dialog_target_properties.cpp b/pcbnew/dialogs/dialog_target_properties.cpp index 0b91f7ea2f..71e93fb836 100644 --- a/pcbnew/dialogs/dialog_target_properties.cpp +++ b/pcbnew/dialogs/dialog_target_properties.cpp @@ -24,10 +24,8 @@ */ #include <pcb_edit_frame.h> -#include <dialog_helpers.h> #include <base_units.h> #include <board_commit.h> -#include <board.h> #include <pcb_target.h> #include <dialog_target_properties_base.h> #include <widgets/unit_binder.h> diff --git a/pcbnew/dialogs/panel_setup_layers.cpp b/pcbnew/dialogs/panel_setup_layers.cpp index b303a46cd8..8e0e61d248 100644 --- a/pcbnew/dialogs/panel_setup_layers.cpp +++ b/pcbnew/dialogs/panel_setup_layers.cpp @@ -36,7 +36,7 @@ #include <wx/choicdlg.h> #include <wx/treebook.h> -#include <dialog_helpers.h> +#include <eda_list_dialog.h> // some define to choose how copper layers widgets are shown diff --git a/pcbnew/dialogs/panel_setup_rules.cpp b/pcbnew/dialogs/panel_setup_rules.cpp index 50a9503cd4..9bd933100d 100644 --- a/pcbnew/dialogs/panel_setup_rules.cpp +++ b/pcbnew/dialogs/panel_setup_rules.cpp @@ -38,7 +38,6 @@ #include <scintilla_tricks.h> #include <drc/drc_rule_parser.h> #include <tools/drc_tool.h> -#include <dialog_helpers.h> PANEL_SETUP_RULES::PANEL_SETUP_RULES( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) : PANEL_SETUP_RULES_BASE( aParent->GetTreebook() ), diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 170b4fb1ac..3ddef78247 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -28,7 +28,7 @@ #include <string_utils.h> #include <macros.h> #include <pcb_edit_frame.h> -#include <dialog_helpers.h> +#include <eda_list_dialog.h> #include <filter_reader.h> #include <fp_lib_table.h> #include <validators.h> diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index bc1037aa44..c54db4e863 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -29,7 +29,6 @@ #include <board.h> #include <footprint.h> #include <confirm.h> -#include <dialog_helpers.h> #include <eda_pattern_match.h> #include <footprint_info.h> #include <footprint_viewer_frame.h> diff --git a/pcbnew/footprint_wizard_frame_functions.cpp b/pcbnew/footprint_wizard_frame_functions.cpp index d22d02f20f..3d3d62edcf 100644 --- a/pcbnew/footprint_wizard_frame_functions.cpp +++ b/pcbnew/footprint_wizard_frame_functions.cpp @@ -24,22 +24,18 @@ */ #include <pcb_edit_frame.h> -#include <dialog_helpers.h> - #include <board.h> #include <footprint.h> - #include <pcbnew.h> #include <pcbnew_id.h> -#include "footprint_wizard_frame.h" #include <wildcards_and_files_ext.h> #include <dialogs/dialog_footprint_wizard_list.h> #include <base_units.h> #include <widgets/wx_grid.h> #include <wx/listbox.h> #include <wx/msgdlg.h> - #include <tool/tool_manager.h> +#include "footprint_wizard_frame.h" void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event ) diff --git a/pcbnew/load_select_footprint.cpp b/pcbnew/load_select_footprint.cpp index fa3e11cad1..10868cfc73 100644 --- a/pcbnew/load_select_footprint.cpp +++ b/pcbnew/load_select_footprint.cpp @@ -32,7 +32,7 @@ using namespace std::placeholders; #include <connectivity/connectivity_data.h> #include <dialog_choose_footprint.h> #include <dialog_get_footprint_by_name.h> -#include <dialog_helpers.h> +#include <eda_list_dialog.h> #include <footprint_edit_frame.h> #include <footprint_info_impl.h> #include <footprint_tree_pane.h> diff --git a/pcbnew/microwave/microwave_footprint.cpp b/pcbnew/microwave/microwave_footprint.cpp index 32ac1ec1dd..f5e33ae54f 100644 --- a/pcbnew/microwave/microwave_footprint.cpp +++ b/pcbnew/microwave/microwave_footprint.cpp @@ -77,7 +77,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint } wxString value = StringFromValue( editFrame.GetUserUnits(), gap_size ); - WX_TEXT_ENTRY_DIALOG dlg( &editFrame, msg, _( "Create microwave footprint" ), value ); + WX_TEXT_ENTRY_DIALOG dlg( &editFrame, msg, _( "Create Microwave Footprint" ), value ); if( dlg.ShowQuasiModal() != wxID_OK ) return nullptr; // cancelled by user @@ -92,7 +92,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint double fcoeff = 10.0, fval; msg.Printf( wxT( "%3.1f" ), angle / fcoeff ); WX_TEXT_ENTRY_DIALOG angledlg( &editFrame, _( "Angle in degrees:" ), - _( "Create microwave footprint" ), msg ); + _( "Create Microwave Footprint" ), msg ); if( angledlg.ShowQuasiModal() != wxID_OK ) return nullptr; // cancelled by user diff --git a/pcbnew/microwave/microwave_polygon.cpp b/pcbnew/microwave/microwave_polygon.cpp index b04b546ee7..674637e36f 100644 --- a/pcbnew/microwave/microwave_polygon.cpp +++ b/pcbnew/microwave/microwave_polygon.cpp @@ -25,16 +25,11 @@ */ #include <confirm.h> -#include <trigo.h> -#include <string_utils.h> +#include <widgets/unit_binder.h> #include <pcb_edit_frame.h> -#include <dialog_helpers.h> #include <dialog_shim.h> #include <locale_io.h> -#include <richio.h> #include <filter_reader.h> -#include <base_units.h> -#include <validators.h> #include <dialogs/dialog_text_entry.h> #include <board.h> #include <footprint.h> @@ -49,12 +44,12 @@ #include <wx/filedlg.h> #include <wx/radiobox.h> #include <wx/sizer.h> +#include <wx/statbox.h> -static std::vector< wxRealPoint > PolyEdges; -static double ShapeScaleX, ShapeScaleY; -static wxSize ShapeSize; -static int PolyShapeType; - +static std::vector< wxRealPoint > g_PolyEdges; +static double g_ShapeScaleX, g_ShapeScaleY; +static wxSize g_ShapeSize; +static int g_PolyShapeType; enum id_mw_cmd { @@ -66,7 +61,12 @@ class MWAVE_POLYGONAL_SHAPE_DLG : public DIALOG_SHIM { public: MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, const wxPoint& pos ); - ~MWAVE_POLYGONAL_SHAPE_DLG() { }; + + ~MWAVE_POLYGONAL_SHAPE_DLG() + { + delete m_sizeX; + delete m_sizeY; + }; bool TransferDataFromWindow() override; @@ -93,9 +93,10 @@ private: DECLARE_EVENT_TABLE() - PCB_EDIT_FRAME* m_Parent; - wxRadioBox* m_ShapeOptionCtrl; - EDA_SIZE_CTRL* m_SizeCtrl; + PCB_EDIT_FRAME* m_frame; + wxRadioBox* m_shapeOptionCtrl; + UNIT_BINDER* m_sizeX; + UNIT_BINDER* m_sizeY; }; @@ -107,40 +108,74 @@ END_EVENT_TABLE() MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, const wxPoint& framepos ) : - DIALOG_SHIM( parent, -1, _( "Complex shape" ), framepos, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) + DIALOG_SHIM( parent, -1, _( "Complex Shape" ), framepos, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ), + m_sizeX(), + m_sizeY() { - m_Parent = parent; + m_frame = parent; - PolyEdges.clear(); + g_PolyEdges.clear(); - wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL ); - SetSizer( MainBoxSizer ); - wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL ); - wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL ); - MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 ); - MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); + wxBoxSizer* mainBoxSizer = new wxBoxSizer( wxVERTICAL ); + SetSizer( mainBoxSizer ); - wxButton* Button = new wxButton( this, wxID_OK, _( "OK" ) ); - RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); + // Controls - Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) ); - RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - - Button = new wxButton( this, ID_READ_SHAPE_FILE, - _( "Read Shape Description File..." ) ); - RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); + wxBoxSizer* topBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + mainBoxSizer->Add( topBoxSizer, 1, wxGROW | wxALL, 5 ); wxString shapelist[] = { _( "Normal" ), _( "Symmetrical" ), _( "Mirrored" ) }; - m_ShapeOptionCtrl = new wxRadioBox( this, -1, _( "Shape Option" ), + m_shapeOptionCtrl = new wxRadioBox( this, -1, _( "Shape" ), wxDefaultPosition, wxDefaultSize, 3, shapelist, 1, wxRA_SPECIFY_COLS ); - LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 ); + topBoxSizer->Add( m_shapeOptionCtrl, 1, wxGROW | wxALL, 5 ); - m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, parent->GetUserUnits(), - LeftBoxSizer ); + auto sizeSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _( "Size" ) ), + wxVERTICAL ); + wxBoxSizer* xSizer = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* ySizer = new wxBoxSizer( wxHORIZONTAL ); + + topBoxSizer->Add( sizeSizer, 1, wxGROW | wxALL, 5 ); + sizeSizer->Add( xSizer, 0, 0, 5 ); + sizeSizer->Add( ySizer, 0, 0, 5 ); + + wxStaticText* xLabel = new wxStaticText( this, -1, _( "X:" ) ); + wxTextCtrl* xCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString ); + wxStaticText* xUnits = new wxStaticText( this, -1, _( "units" ) ); + + xSizer->Add( xLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); + xSizer->Add( xCtrl, 1, wxALIGN_CENTER_VERTICAL, 5 ); + xSizer->Add( xUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); + m_sizeX = new UNIT_BINDER( m_frame, xLabel, xCtrl, xUnits ); + + wxStaticText* yLabel = new wxStaticText( this, -1, _( "Y:" ) ); + wxTextCtrl* yCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString ); + wxStaticText* yUnits = new wxStaticText( this, -1, _( "units" ) ); + + ySizer->Add( yLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); + ySizer->Add( yCtrl, 1, wxALIGN_CENTER_VERTICAL, 5 ); + ySizer->Add( yUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); + m_sizeY = new UNIT_BINDER( m_frame, yLabel, yCtrl, yUnits ); + + // Buttons + + wxBoxSizer* buttonsBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + mainBoxSizer->Add( buttonsBoxSizer, 0, wxALL, 5 ); + + wxButton* btn = new wxButton( this, ID_READ_SHAPE_FILE, _( "Read Shape Description File..." ) ); + buttonsBoxSizer->Add( btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 10 ); + buttonsBoxSizer->AddStretchSpacer(); + + wxStdDialogButtonSizer* sdbSizer = new wxStdDialogButtonSizer(); + buttonsBoxSizer->Add( sdbSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); + wxButton* sdbSizerOK = new wxButton( this, wxID_OK ); + sdbSizer->AddButton( sdbSizerOK ); + wxButton* sdbSizerCancel = new wxButton( this, wxID_CANCEL ); + sdbSizer->AddButton( sdbSizerCancel ); + sdbSizer->Realize(); GetSizer()->SetSizeHints( this ); } @@ -148,7 +183,7 @@ MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, void MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick( wxCommandEvent& event ) { - PolyEdges.clear(); + g_PolyEdges.clear(); event.Skip(); } @@ -158,8 +193,9 @@ bool MWAVE_POLYGONAL_SHAPE_DLG::TransferDataFromWindow() if( !wxDialog::TransferDataFromWindow() ) return false; - ShapeSize = m_SizeCtrl->GetValue(); - PolyShapeType = m_ShapeOptionCtrl->GetSelection(); + g_ShapeSize.x = m_sizeX->GetValue(); + g_ShapeSize.y = m_sizeY->GetValue(); + g_PolyShapeType = m_shapeOptionCtrl->GetSelection(); return true; } @@ -167,19 +203,19 @@ bool MWAVE_POLYGONAL_SHAPE_DLG::TransferDataFromWindow() void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event ) { - static wxString lastpath; // To remember the last open path during a session + static wxString s_lastpath; // To remember the last open path during a session wxString fullFileName; wxString mask = wxFileSelectorDefaultWildcardStr; - fullFileName = wxFileSelector( _( "Shape Description File" ), lastpath, + fullFileName = wxFileSelector( _( "Shape Description File" ), s_lastpath, fullFileName, wxEmptyString, mask, wxFD_OPEN, this ); if( fullFileName.IsEmpty() ) return; wxFileName fn( fullFileName ); - lastpath = fn.GetPath(); - PolyEdges.clear(); + s_lastpath = fn.GetPath(); + g_PolyEdges.clear(); FILE* File = wxFopen( fullFileName, wxT( "rt" ) ); @@ -190,7 +226,7 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event ) } double unitconv = IU_PER_MM; - ShapeScaleX = ShapeScaleY = 1.0; + g_ShapeScaleX = g_ShapeScaleY = 1.0; FILE_LINE_READER fileReader( File, fullFileName ); FILTER_READER reader( fileReader ); @@ -227,21 +263,22 @@ void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr( wxCommandEvent& event ) break; wxRealPoint coord( atof( param1 ), atof( param2 ) ); - PolyEdges.push_back( coord ); + g_PolyEdges.push_back( coord ); } } if( strncasecmp( Line, "XScale", 6 ) == 0 ) - ShapeScaleX = atof( param2 ); + g_ShapeScaleX = atof( param2 ); if( strncasecmp( Line, "YScale", 6 ) == 0 ) - ShapeScaleY = atof( param2 ); + g_ShapeScaleY = atof( param2 ); } - ShapeScaleX *= unitconv; - ShapeScaleY *= unitconv; + g_ShapeScaleX *= unitconv; + g_ShapeScaleY *= unitconv; - m_SizeCtrl->SetValue( (int) ShapeScaleX, (int) ShapeScaleY ); + m_sizeX->SetValue( (int) g_ShapeScaleX ); + m_sizeY->SetValue( (int) g_ShapeScaleY ); } @@ -262,23 +299,23 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape() if( ret != wxID_OK ) { - PolyEdges.clear(); + g_PolyEdges.clear(); return nullptr; } - if( PolyShapeType == 2 ) // mirrored - ShapeScaleY = -ShapeScaleY; + if( g_PolyShapeType == 2 ) // mirrored + g_ShapeScaleY = -g_ShapeScaleY; - ShapeSize.x = KiROUND( ShapeScaleX ); - ShapeSize.y = KiROUND( ShapeScaleY ); + g_ShapeSize.x = KiROUND( g_ShapeScaleX ); + g_ShapeSize.y = KiROUND( g_ShapeScaleY ); - if( ( ShapeSize.x ) == 0 || ( ShapeSize.y == 0 ) ) + if(( g_ShapeSize.x ) == 0 || ( g_ShapeSize.y == 0 ) ) { editFrame.ShowInfoBarError( _( "Shape has a null size." ) ); return nullptr; } - if( PolyEdges.size() == 0 ) + if( g_PolyEdges.size() == 0 ) { editFrame.ShowInfoBarError( _( "Shape has no points." ) ); return nullptr; @@ -291,7 +328,7 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape() // We try to place the footprint anchor to the middle of the shape len wxPoint offset; - offset.x = -ShapeSize.x / 2; + offset.x = -g_ShapeSize.x / 2; auto it = footprint->Pads().begin(); @@ -300,7 +337,7 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape() pad1->SetX( pad1->GetPos0().x ); pad2 = *( ++it ); - pad2->SetX0( offset.x + ShapeSize.x ); + pad2->SetX0( offset.x + g_ShapeSize.x ); pad2->SetX( pad2->GetPos0().x ); // Add a polygonal edge (corners will be added later) on copper layer @@ -313,17 +350,17 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape() // Get the corner buffer of the polygonal edge std::vector<wxPoint> polyPoints; - polyPoints.reserve( PolyEdges.size() + 2 ); + polyPoints.reserve( g_PolyEdges.size() + 2 ); // Init start point coord: polyPoints.emplace_back( wxPoint( offset.x, 0 ) ); wxPoint last_coordinate; - for( wxRealPoint& pt: PolyEdges ) // Copy points + for( wxRealPoint& pt: g_PolyEdges ) // Copy points { - last_coordinate.x = KiROUND( pt.x * ShapeScaleX ); - last_coordinate.y = -KiROUND( pt.y * ShapeScaleY ); + last_coordinate.x = KiROUND( pt.x * g_ShapeScaleX ); + last_coordinate.y = -KiROUND( pt.y * g_ShapeScaleY ); last_coordinate += offset; polyPoints.push_back( last_coordinate ); } @@ -332,7 +369,7 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape() if( last_coordinate.y != 0 ) polyPoints.emplace_back( wxPoint( last_coordinate.x, 0 ) ); - switch( PolyShapeType ) + switch( g_PolyShapeType ) { case 0: // shape from file case 2: // shape from file, mirrored (the mirror is already done) @@ -354,7 +391,7 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape() // Set the polygon outline thickness to 0, only the polygonal shape is filled // without extra thickness. shape->SetWidth( 0 ); - PolyEdges.clear(); + g_PolyEdges.clear(); editFrame.OnModify(); return footprint; diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 0f5191188e..fde917d38d 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -34,7 +34,6 @@ #include <kiface_i.h> #include <confirm.h> -#include <dialog_helpers.h> #include <pcb_base_frame.h> #include <base_units.h> #include <widgets/msgpanel.h> diff --git a/pcbnew/toolbars_footprint_editor.cpp b/pcbnew/toolbars_footprint_editor.cpp index 22c386f22c..02e3a55b95 100644 --- a/pcbnew/toolbars_footprint_editor.cpp +++ b/pcbnew/toolbars_footprint_editor.cpp @@ -22,7 +22,6 @@ #include <tool/actions.h> #include <footprint_edit_frame.h> -#include <dialog_helpers.h> #include <pcbnew_id.h> #include <bitmaps.h> #include <tool/action_toolbar.h> diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index ca51b94ff2..de4a19d1c6 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -30,7 +30,6 @@ #include <bitmaps.h> #include <board.h> #include <board_design_settings.h> -#include <dialog_helpers.h> #include <kiface_i.h> #include <macros.h> #include <pcb_edit_frame.h> diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index daf0bdcb5d..40d153a8d9 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -23,7 +23,7 @@ #include <bitmaps.h> #include <board.h> #include <board_design_settings.h> -#include <dialog_helpers.h> +#include <eda_list_dialog.h> #include <footprint_edit_frame.h> #include <menus_helpers.h> #include <pcb_display_options.h>