diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 79f7277249..d3656d1e84 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -142,8 +143,6 @@ DIALOG_SHIM::~DIALOG_SHIM() { m_isClosing = true; - SaveControlState(); - Unbind( wxEVT_CLOSE_WINDOW, &DIALOG_SHIM::OnCloseWindow, this ); Unbind( wxEVT_BUTTON, &DIALOG_SHIM::OnButton, this ); Unbind( wxEVT_PAINT, &DIALOG_SHIM::OnPaint, this ); @@ -158,14 +157,12 @@ DIALOG_SHIM::~DIALOG_SHIM() { if( wxTextCtrl* textCtrl = dynamic_cast( child ) ) { - textCtrl->Disconnect( wxEVT_SET_FOCUS, - wxFocusEventHandler( DIALOG_SHIM::onChildSetFocus ), + textCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_SHIM::onChildSetFocus ), nullptr, this ); } else if( wxStyledTextCtrl* scintilla = dynamic_cast( child ) ) { - scintilla->Disconnect( wxEVT_SET_FOCUS, - wxFocusEventHandler( DIALOG_SHIM::onChildSetFocus ), + scintilla->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_SHIM::onChildSetFocus ), nullptr, this ); } else @@ -316,6 +313,8 @@ bool DIALOG_SHIM::Show( bool show ) ret = wxDialog::Show( show ); + SaveControlState(); + if( m_parent ) m_parent->SetFocus(); } @@ -428,10 +427,14 @@ void DIALOG_SHIM::SaveControlState() if( !key.empty() ) { - if( wxComboBox* combo = dynamic_cast( win ) ) + if( m_unitBinders.contains( win ) && !m_unitBinders[ win ]->UnitsInvariant() ) + dlgMap[ key ] = m_unitBinders[ win ]->GetValue(); + else if( wxComboBox* combo = dynamic_cast( win ) ) dlgMap[ key ] = combo->GetValue(); else if( wxOwnerDrawnComboBox* od_combo = dynamic_cast( win ) ) dlgMap[ key ] = od_combo->GetSelection(); + else if( wxTextEntry* textEntry = dynamic_cast( win ) ) + dlgMap[ key ] = textEntry->GetValue(); else if( wxChoice* choice = dynamic_cast( win ) ) dlgMap[ key ] = choice->GetSelection(); else if( wxCheckBox* check = dynamic_cast( win ) ) @@ -495,7 +498,12 @@ void DIALOG_SHIM::LoadControlState() { const nlohmann::json& j = it->second; - if( wxComboBox* combo = dynamic_cast( win ) ) + if( m_unitBinders.contains( win ) && !m_unitBinders[ win ]->UnitsInvariant() ) + { + if( j.is_number_integer() ) + m_unitBinders[ win ]->SetValue( j.get() ); + } + else if( wxComboBox* combo = dynamic_cast( win ) ) { if( j.is_string() ) combo->SetValue( wxString::FromUTF8( j.get().c_str() ) ); @@ -505,6 +513,11 @@ void DIALOG_SHIM::LoadControlState() if( j.is_number_integer() ) od_combo->SetSelection( j.get() ); } + else if( wxTextEntry* textEntry = dynamic_cast( win ) ) + { + if( j.is_string() ) + textEntry->ChangeValue( wxString::FromUTF8( j.get().c_str() ) ); + } else if( wxChoice* choice = dynamic_cast( win ) ) { if( j.is_number_integer() ) @@ -563,6 +576,20 @@ void DIALOG_SHIM::LoadControlState() } +void DIALOG_SHIM::OptOut( wxWindow* aWindow ) +{ + PROPERTY_HOLDER* props = new PROPERTY_HOLDER(); + props->SetProperty( "persist", false ); + aWindow->SetClientData( props ); +} + + +void DIALOG_SHIM::RegisterUnitBinder( UNIT_BINDER* aUnitBinder, wxWindow* aWindow ) +{ + m_unitBinders[ aWindow ] = aUnitBinder; +} + + // Recursive descent doing a SelectAll() in wxTextCtrls. // MacOS User Interface Guidelines state that when tabbing to a text control all its // text should be selected. Since wxWidgets fails to implement this, we do it here. @@ -719,8 +746,7 @@ int DIALOG_SHIM::ShowQuasiModal() // Get the optimal parent wxWindow* parent = GetParentForModalDialog( GetParent(), GetWindowStyle() ); - wxASSERT_MSG( !m_qmodal_parent_disabler, wxT( "Caller using ShowQuasiModal() twice on same " - "window?" ) ); + wxASSERT_MSG( !m_qmodal_parent_disabler, wxT( "Caller using ShowQuasiModal() twice on same window?" ) ); // quasi-modal: disable only my "optimal" parent m_qmodal_parent_disabler = new WINDOW_DISABLER( parent ); diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 3b8bceaa38..6acf724c43 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include "widgets/unit_binder.h" #include "wx/dcclient.h" @@ -55,16 +56,31 @@ UNIT_BINDER::UNIT_BINDER( UNITS_PROVIDER* aUnitsProvider, wxWindow* aEventSource m_eventSource( aEventSource ), m_unitLabel( aUnitLabel ), m_iuScale( &aUnitsProvider->GetIuScale() ), + m_units( aUnitsProvider->GetUserUnits() ), m_negativeZero( false ), m_dataType( EDA_DATA_TYPE::DISTANCE ), m_precision( 0 ), m_eval( aUnitsProvider->GetUserUnits() ), + m_allowEval( aAllowEval && ( !m_valueCtrl || dynamic_cast( m_valueCtrl ) ) ), + m_needsEval( false ), + m_selStart( 0 ), + m_selEnd( 0 ), m_unitsInValue( false ), m_originTransforms( aUnitsProvider->GetOriginTransforms() ), m_coordType( ORIGIN_TRANSFORMS::NOT_A_COORD ) { - init( aUnitsProvider ); - m_allowEval = aAllowEval && ( !m_valueCtrl || dynamic_cast( m_valueCtrl ) ); + if( m_valueCtrl ) + { + // Register the UNIT_BINDER for control state save/restore + wxWindow* parent = m_valueCtrl->GetParent(); + + while( parent && !dynamic_cast( parent ) ) + parent = parent->GetParent(); + + if( parent ) + static_cast( parent )->RegisterUnitBinder( this, m_valueCtrl ); + } + wxTextEntry* textEntry = dynamic_cast( m_valueCtrl ); if( textEntry ) @@ -129,15 +145,6 @@ UNIT_BINDER::~UNIT_BINDER() } -void UNIT_BINDER::init( UNITS_PROVIDER* aProvider ) -{ - m_units = aProvider->GetUserUnits(); - m_needsEval = false; - m_selStart = 0; - m_selEnd = 0; -} - - void UNIT_BINDER::SetUnits( EDA_UNITS aUnits ) { m_units = aUnits; @@ -169,9 +176,7 @@ void UNIT_BINDER::onUnitsChanged( wxCommandEvent& aEvent ) { EDA_BASE_FRAME* provider = static_cast( aEvent.GetClientData() ); - if( m_units != EDA_UNITS::UNSCALED - && m_units != EDA_UNITS::DEGREES - && m_units != EDA_UNITS::PERCENT ) + if( !UnitsInvariant() ) { int temp = GetIntValue(); diff --git a/include/dialog_shim.h b/include/dialog_shim.h index 46a3789fd6..1ba6278f75 100644 --- a/include/dialog_shim.h +++ b/include/dialog_shim.h @@ -33,6 +33,7 @@ #include class EDA_BASE_FRAME; +class UNIT_BINDER; class wxGridEvent; class wxGUIEventLoop; @@ -140,6 +141,20 @@ public: */ void SaveControlState(); + /** + * Opt out of control state saving. + * @param aWindow can be either a specific control, or the whole dialog + */ + void OptOut( wxWindow* aWindow ); + + /** + * Register a UNIT_BINDER so that it can handle units in control-state save/restore + * + * @param aUnitBinder + * @param aWindow the control window + */ + void RegisterUnitBinder( UNIT_BINDER* aUnitBinder, wxWindow* aWindow ); + protected: /** * In all dialogs, we must call the same functions to fix minimal dlg size, the default @@ -245,9 +260,9 @@ protected: bool m_userPositioned; bool m_userResized; - // Used to support first-esc-cancels-edit logic - std::map m_beforeEditValues; + std::map m_beforeEditValues; + std::map m_unitBinders; }; #endif // DIALOG_SHIM_ diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index b7a5f468d9..745949f9de 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -70,6 +70,11 @@ public: */ virtual void SetUnits( EDA_UNITS aUnits ); + bool UnitsInvariant() const + { + return m_units == EDA_UNITS::UNSCALED || m_units == EDA_UNITS::DEGREES || m_units == EDA_UNITS::PERCENT; + } + virtual void SetNegativeZero() { m_negativeZero = true; } /** @@ -211,7 +216,6 @@ public: } protected: - void init( UNITS_PROVIDER* aProvider ); void onClick( wxMouseEvent& aEvent ); void onComboBox( wxCommandEvent& aEvent ); diff --git a/pcbnew/dialogs/dialog_global_deletion.cpp b/pcbnew/dialogs/dialog_global_deletion.cpp index f3aaba83d7..9cf46aaa26 100644 --- a/pcbnew/dialogs/dialog_global_deletion.cpp +++ b/pcbnew/dialogs/dialog_global_deletion.cpp @@ -53,9 +53,7 @@ DIALOG_GLOBAL_DELETION::DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent ) : m_drawingFilterUnlocked->Enable( m_delDrawings->GetValue() ); // This is a destructive dialog. Don't save control state; we always want to come up in a benign state. - PROPERTY_HOLDER* props = new PROPERTY_HOLDER(); - props->SetProperty( "persist", false ); - SetClientData( props ); + OptOut( this ); SetupStandardButtons(); diff --git a/pcbnew/dialogs/dialog_move_exact.cpp b/pcbnew/dialogs/dialog_move_exact.cpp index d7f374a9b8..103101f51b 100644 --- a/pcbnew/dialogs/dialog_move_exact.cpp +++ b/pcbnew/dialogs/dialog_move_exact.cpp @@ -29,13 +29,10 @@ #include #include -// initialise statics -DIALOG_MOVE_EXACT::MOVE_EXACT_OPTIONS DIALOG_MOVE_EXACT::m_options; -DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME *aParent, VECTOR2I& aTranslate, - EDA_ANGLE& aRotate, ROTATION_ANCHOR& aAnchor, - const BOX2I& aBbox ) : +DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME *aParent, VECTOR2I& aTranslate, EDA_ANGLE& aRotate, + ROTATION_ANCHOR& aAnchor, const BOX2I& aBbox ) : DIALOG_MOVE_EXACT_BASE( aParent ), m_translation( aTranslate ), m_rotation( aRotate ), @@ -63,8 +60,6 @@ DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME *aParent, VECTOR2I& aTransl m_moveX.SetCoordType( ORIGIN_TRANSFORMS::REL_X_COORD ); m_moveY.SetCoordType( ORIGIN_TRANSFORMS::REL_Y_COORD ); - updateDialogControls( m_options.polarCoords ); - m_menuIDs.push_back( aAnchor ); m_menuIDs.push_back( ROTATE_AROUND_USER_ORIGIN ); @@ -72,20 +67,7 @@ DIALOG_MOVE_EXACT::DIALOG_MOVE_EXACT( PCB_BASE_FRAME *aParent, VECTOR2I& aTransl m_menuIDs.push_back( ROTATE_AROUND_AUX_ORIGIN ); buildRotationAnchorMenu(); - - // and set up the entries according to the saved options - m_polarCoords->SetValue( m_options.polarCoords ); - m_xEntry->ChangeValue( m_options.entry1 ); - m_yEntry->ChangeValue( m_options.entry2 ); - - // Force the evaluation when setting previous values - m_moveX.RequireEval(); - m_moveY.RequireEval(); - m_rotate.RequireEval(); - m_rotate.SetUnits( EDA_UNITS::DEGREES ); - m_rotate.SetValue( m_options.entryRotation ); - m_anchorOptions->SetSelection( std::min( m_options.entryAnchorSelection, m_menuIDs.size() ) ); SetupStandardButtons(); @@ -97,22 +79,14 @@ void DIALOG_MOVE_EXACT::buildRotationAnchorMenu() { wxArrayString menuItems; - for( auto anchorID : m_menuIDs ) + for( const ROTATION_ANCHOR& anchorID : m_menuIDs ) { switch( anchorID ) { - case ROTATE_AROUND_ITEM_ANCHOR: - menuItems.push_back( _( "Rotate around item anchor" ) ); - break; - case ROTATE_AROUND_SEL_CENTER: - menuItems.push_back( _( "Rotate around selection center" ) ); - break; - case ROTATE_AROUND_USER_ORIGIN: - menuItems.push_back( _( "Rotate around local coordinates origin" ) ); - break; - case ROTATE_AROUND_AUX_ORIGIN: - menuItems.push_back( _( "Rotate around drill/place origin" ) ); - break; + case ROTATE_AROUND_ITEM_ANCHOR: menuItems.push_back( _( "Rotate around item anchor" ) ); break; + case ROTATE_AROUND_SEL_CENTER: menuItems.push_back( _( "Rotate around selection center" ) ); break; + case ROTATE_AROUND_USER_ORIGIN: menuItems.push_back( _( "Rotate around local coordinates origin" ) ); break; + case ROTATE_AROUND_AUX_ORIGIN: menuItems.push_back( _( "Rotate around drill/place origin" ) ); break; } } @@ -241,6 +215,19 @@ void DIALOG_MOVE_EXACT::OnClear( wxCommandEvent& event ) } +bool DIALOG_MOVE_EXACT::TransferDataToWindow() +{ + updateDialogControls( m_polarCoords->GetValue() ); + + // Force the evaluation when setting previous values + m_moveX.RequireEval(); + m_moveY.RequireEval(); + m_rotate.RequireEval(); + + return true; +} + + bool DIALOG_MOVE_EXACT::TransferDataFromWindow() { // for the output, we only deliver a Cartesian vector @@ -251,13 +238,6 @@ bool DIALOG_MOVE_EXACT::TransferDataFromWindow() m_rotation = m_rotate.GetAngleValue(); m_rotationAnchor = m_menuIDs[ m_anchorOptions->GetSelection() ]; - // save the settings - m_options.polarCoords = m_polarCoords->GetValue(); - m_options.entry1 = m_xEntry->GetValue(); - m_options.entry2 = m_yEntry->GetValue(); - m_options.entryRotation = m_rotEntry->GetValue(); - m_options.entryAnchorSelection = (size_t) std::max( m_anchorOptions->GetSelection(), 0 ); - return ok; } @@ -302,5 +282,4 @@ void DIALOG_MOVE_EXACT::OnTextChanged( wxCommandEvent& event ) m_stdButtons->GetAffirmativeButton()->Enable(); event.Skip(); } - } diff --git a/pcbnew/dialogs/dialog_move_exact.h b/pcbnew/dialogs/dialog_move_exact.h index 6ce89df37e..18268f41b2 100644 --- a/pcbnew/dialogs/dialog_move_exact.h +++ b/pcbnew/dialogs/dialog_move_exact.h @@ -22,8 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef __DIALOG_MOVE_EXACT__ -#define __DIALOG_MOVE_EXACT__ +#pragma once #include #include @@ -63,7 +62,7 @@ private: void OnClear( wxCommandEvent& event ) override; void OnTextChanged( wxCommandEvent& event ) override; - // Automatically called when clicking on the OK button + bool TransferDataToWindow() override; bool TransferDataFromWindow() override; /** @@ -87,30 +86,6 @@ private: // Update controls and their labels after changing the coordinates type (polar/cartesian) void updateDialogControls( bool aPolar ); - /** - * Persistent dialog options - */ - struct MOVE_EXACT_OPTIONS - { - bool polarCoords; - wxString entry1; - wxString entry2; - wxString entryRotation; - size_t entryAnchorSelection; - - MOVE_EXACT_OPTIONS(): - polarCoords( false ), - entry1( wxT( "0" ) ), - entry2( wxT( "0" ) ), - entryRotation( wxT( "0" ) ), - entryAnchorSelection( 0 ) - { - } - }; - - // persistent settings - static MOVE_EXACT_OPTIONS m_options; - private: VECTOR2I& m_translation; EDA_ANGLE& m_rotation; @@ -128,5 +103,3 @@ private: double m_stateRadius; EDA_ANGLE m_stateTheta; }; - -#endif // __DIALOG_MOVE_EXACT__ diff --git a/pcbnew/dialogs/dialog_position_relative.cpp b/pcbnew/dialogs/dialog_position_relative.cpp index dab2022472..7dec4fc320 100644 --- a/pcbnew/dialogs/dialog_position_relative.cpp +++ b/pcbnew/dialogs/dialog_position_relative.cpp @@ -33,7 +33,7 @@ #include // initialise statics -DIALOG_POSITION_RELATIVE::POSITION_RELATIVE_OPTIONS DIALOG_POSITION_RELATIVE::m_options; +DIALOG_POSITION_RELATIVE::ANCHOR_TYPE DIALOG_POSITION_RELATIVE::s_anchorType = DIALOG_POSITION_RELATIVE::ANCHOR_ITEM; DIALOG_POSITION_RELATIVE::DIALOG_POSITION_RELATIVE( PCB_BASE_FRAME* aParent ) : @@ -60,13 +60,8 @@ DIALOG_POSITION_RELATIVE::DIALOG_POSITION_RELATIVE( PCB_BASE_FRAME* aParent ) : SetInitialFocus( m_xEntry ); - // and set up the entries according to the saved options - m_polarCoords->SetValue( m_options.polarCoords ); updateDialogControls( m_polarCoords->IsChecked() ); - m_xOffset.SetDoubleValue( m_options.entry1 ); - m_yOffset.SetDoubleValue( m_options.entry2 ); - SetupStandardButtons(); finishDialogSettings(); @@ -241,7 +236,7 @@ void DIALOG_POSITION_RELATIVE::OnSelectPointClick( wxCommandEvent& event ) void DIALOG_POSITION_RELATIVE::updateAnchorInfo( const BOARD_ITEM* aItem ) { - switch( m_options.anchorType ) + switch( s_anchorType ) { case ANCHOR_GRID_ORIGIN: m_referenceInfo->SetLabel( _( "Reference location: grid origin" ) ); @@ -274,7 +269,7 @@ void DIALOG_POSITION_RELATIVE::updateAnchorInfo( const BOARD_ITEM* aItem ) VECTOR2I DIALOG_POSITION_RELATIVE::getAnchorPos() { - switch( m_options.anchorType ) + switch( s_anchorType ) { case ANCHOR_GRID_ORIGIN: return static_cast( m_toolMgr->GetModel() )->GetDesignSettings().GetGridOrigin(); @@ -294,14 +289,14 @@ VECTOR2I DIALOG_POSITION_RELATIVE::getAnchorPos() void DIALOG_POSITION_RELATIVE::OnUseGridOriginClick( wxCommandEvent& event ) { - m_options.anchorType = ANCHOR_GRID_ORIGIN; + s_anchorType = ANCHOR_GRID_ORIGIN; updateAnchorInfo( nullptr ); } void DIALOG_POSITION_RELATIVE::OnUseUserOriginClick( wxCommandEvent& event ) { - m_options.anchorType = ANCHOR_USER_ORIGIN; + s_anchorType = ANCHOR_USER_ORIGIN; updateAnchorInfo( nullptr ); } @@ -313,7 +308,7 @@ void DIALOG_POSITION_RELATIVE::UpdatePickedItem( const EDA_ITEM* aItem ) if( aItem && aItem->IsBOARD_ITEM() ) item = static_cast( aItem ); - m_options.anchorType = ANCHOR_ITEM; + s_anchorType = ANCHOR_ITEM; updateAnchorInfo( item ); if( item ) @@ -325,7 +320,7 @@ void DIALOG_POSITION_RELATIVE::UpdatePickedItem( const EDA_ITEM* aItem ) void DIALOG_POSITION_RELATIVE::UpdatePickedPoint( const std::optional& aPoint ) { - m_options.anchorType = ANCHOR_POINT; + s_anchorType = ANCHOR_POINT; if( aPoint ) m_anchorItemPosition = *aPoint; @@ -343,11 +338,6 @@ void DIALOG_POSITION_RELATIVE::OnOkClick( wxCommandEvent& event ) if( getTranslationInIU( translation, m_polarCoords->IsChecked() ) ) { - // save the settings - m_options.polarCoords = m_polarCoords->GetValue(); - m_options.entry1 = m_xOffset.GetDoubleValue(); - m_options.entry2 = m_yOffset.GetDoubleValue(); - POSITION_RELATIVE_TOOL* posrelTool = m_toolMgr->GetTool(); posrelTool->RelativeItemSelectionMove( getAnchorPos(), translation ); diff --git a/pcbnew/dialogs/dialog_position_relative.h b/pcbnew/dialogs/dialog_position_relative.h index 8d5c3b85f2..3253a088ca 100644 --- a/pcbnew/dialogs/dialog_position_relative.h +++ b/pcbnew/dialogs/dialog_position_relative.h @@ -21,8 +21,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef __DIALOG_POSITION_RELATIVE__ -#define __DIALOG_POSITION_RELATIVE__ +#pragma once // Include the wxFormBuider header base: #include @@ -38,7 +37,7 @@ class DIALOG_POSITION_RELATIVE : public DIALOG_POSITION_RELATIVE_BASE, public: // Constructor and destructor DIALOG_POSITION_RELATIVE( PCB_BASE_FRAME* aParent ); - ~DIALOG_POSITION_RELATIVE() { }; + ~DIALOG_POSITION_RELATIVE() = default; // Implement the RECEIVER interface for the callback from the TOOL void UpdatePickedItem( const EDA_ITEM* aItem ) override; @@ -84,6 +83,7 @@ private: // Get the current anchor position. VECTOR2I getAnchorPos(); +private: /** * Persistent dialog options. */ @@ -95,25 +95,9 @@ private: ANCHOR_POINT }; - struct POSITION_RELATIVE_OPTIONS - { - ANCHOR_TYPE anchorType; - bool polarCoords; - double entry1; - double entry2; - - POSITION_RELATIVE_OPTIONS() : - anchorType( ANCHOR_ITEM ), - polarCoords( false ), - entry1( 0 ), - entry2( 0 ) - { - } - }; - - // persistent settings - static POSITION_RELATIVE_OPTIONS m_options; + static ANCHOR_TYPE s_anchorType; +private: TOOL_MANAGER* m_toolMgr; VECTOR2I m_anchorItemPosition; @@ -125,5 +109,3 @@ private: double m_stateRadius; EDA_ANGLE m_stateTheta; }; - -#endif // __DIALOG_POSITION_RELATIVE__ diff --git a/pcbnew/dialogs/dialog_print_pcbnew.cpp b/pcbnew/dialogs/dialog_print_pcbnew.cpp index 7e0e980dfa..c7a6643c0c 100644 --- a/pcbnew/dialogs/dialog_print_pcbnew.cpp +++ b/pcbnew/dialogs/dialog_print_pcbnew.cpp @@ -126,23 +126,19 @@ DIALOG_PRINT_PCBNEW::DIALOG_PRINT_PCBNEW( PCB_BASE_EDIT_FRAME* aParent, finishDialogSettings(); - m_popMenu->Bind( wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onPopUpLayers ), this, - ID_SELECT_FIRST, ID_SELECT_LAST ); + m_popMenu->Bind( wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onPopUpLayers ), + this, ID_SELECT_FIRST, ID_SELECT_LAST ); - m_outputMode->Bind( wxEVT_COMMAND_CHOICE_SELECTED, &DIALOG_PRINT_PCBNEW::onColorModeClicked, - this ); + m_outputMode->Bind( wxEVT_COMMAND_CHOICE_SELECTED, &DIALOG_PRINT_PCBNEW::onColorModeClicked, this ); } DIALOG_PRINT_PCBNEW::~DIALOG_PRINT_PCBNEW() { - m_popMenu->Unbind( wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onPopUpLayers ), this, - ID_SELECT_FIRST, ID_SELECT_LAST ); + m_popMenu->Unbind( wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onPopUpLayers ), + this, ID_SELECT_FIRST, ID_SELECT_LAST ); - m_outputMode->Unbind( wxEVT_COMMAND_CHOICE_SELECTED, &DIALOG_PRINT_PCBNEW::onColorModeClicked, - this ); + m_outputMode->Unbind( wxEVT_COMMAND_CHOICE_SELECTED, &DIALOG_PRINT_PCBNEW::onColorModeClicked, this ); } diff --git a/pcbnew/dialogs/dialog_push_pad_properties.cpp b/pcbnew/dialogs/dialog_push_pad_properties.cpp index c2fe516a9b..a29e0d2058 100644 --- a/pcbnew/dialogs/dialog_push_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_push_pad_properties.cpp @@ -21,7 +21,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - #include #include @@ -29,23 +28,10 @@ #include -// Class DIALOG_PUSH_PAD_PROPERTIES static variables -bool DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Shape_Filter = true; -bool DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Layer_Filter = true; -bool DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Orient_Filter = true; -bool DIALOG_PUSH_PAD_PROPERTIES::m_Pad_Type_Filter = true; - - DIALOG_PUSH_PAD_PROPERTIES::DIALOG_PUSH_PAD_PROPERTIES( PCB_BASE_FRAME* aParent ) : - DIALOG_PUSH_PAD_PROPERTIES_BASE( aParent ), - m_parent( aParent ) + DIALOG_PUSH_PAD_PROPERTIES_BASE( aParent ), + m_parent( aParent ) { - // Pad filter selection. - m_Pad_Shape_Filter_CB->SetValue( m_Pad_Shape_Filter ); - m_Pad_Layer_Filter_CB->SetValue( m_Pad_Layer_Filter ); - m_Pad_Orient_Filter_CB->SetValue( m_Pad_Orient_Filter ); - m_Pad_Type_Filter_CB->SetValue( m_Pad_Type_Filter ); - SetupStandardButtons( { { wxID_OK, _( "Change Pads on Current Footprint" ) }, { wxID_APPLY, _( "Change Pads on Identical Footprints" ) } } ); @@ -69,11 +55,6 @@ void DIALOG_PUSH_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) KI_FALLTHROUGH; case wxID_OK: - m_Pad_Shape_Filter = m_Pad_Shape_Filter_CB->GetValue(); - m_Pad_Layer_Filter = m_Pad_Layer_Filter_CB->GetValue(); - m_Pad_Orient_Filter = m_Pad_Orient_Filter_CB->GetValue(); - m_Pad_Type_Filter = m_Pad_Type_Filter_CB->GetValue(); - if( IsQuasiModal() ) EndQuasiModal( returncode ); else diff --git a/pcbnew/dialogs/dialog_push_pad_properties.h b/pcbnew/dialogs/dialog_push_pad_properties.h index 12eb854da2..c066b9e0dc 100644 --- a/pcbnew/dialogs/dialog_push_pad_properties.h +++ b/pcbnew/dialogs/dialog_push_pad_properties.h @@ -21,8 +21,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef __DIALOG_GLOBAL_PADS_EDITION_H -#define __DIALOG_GLOBAL_PADS_EDITION_H +#pragma once #include @@ -38,15 +37,8 @@ public: private: void PadPropertiesAccept( wxCommandEvent& event ) override; -public: - static bool m_Pad_Shape_Filter; - static bool m_Pad_Layer_Filter; - static bool m_Pad_Orient_Filter; - static bool m_Pad_Type_Filter; - private: PCB_BASE_FRAME* m_parent; }; -#endif // __DIALOG_GLOBAL_PADS_EDITION_H diff --git a/pcbnew/dialogs/dialog_push_pad_properties_base.cpp b/pcbnew/dialogs/dialog_push_pad_properties_base.cpp index 68b483b793..1b528c19c1 100644 --- a/pcbnew/dialogs/dialog_push_pad_properties_base.cpp +++ b/pcbnew/dialogs/dialog_push_pad_properties_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -23,15 +23,19 @@ DIALOG_PUSH_PAD_PROPERTIES_BASE::DIALOG_PUSH_PAD_PROPERTIES_BASE( wxWindow* pare sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL ); m_Pad_Shape_Filter_CB = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Do not modify pads having a different shape"), wxDefaultPosition, wxDefaultSize, 0 ); + m_Pad_Shape_Filter_CB->SetValue(true); sbSizer1->Add( m_Pad_Shape_Filter_CB, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_Pad_Layer_Filter_CB = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Do not modify pads having different layers"), wxDefaultPosition, wxDefaultSize, 0 ); + m_Pad_Layer_Filter_CB->SetValue(true); sbSizer1->Add( m_Pad_Layer_Filter_CB, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_Pad_Orient_Filter_CB = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Do not modify pads having a different orientation"), wxDefaultPosition, wxDefaultSize, 0 ); + m_Pad_Orient_Filter_CB->SetValue(true); sbSizer1->Add( m_Pad_Orient_Filter_CB, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_Pad_Type_Filter_CB = new wxCheckBox( sbSizer1->GetStaticBox(), wxID_ANY, _("Do not modify pads having a different type"), wxDefaultPosition, wxDefaultSize, 0 ); + m_Pad_Type_Filter_CB->SetValue(true); sbSizer1->Add( m_Pad_Type_Filter_CB, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); diff --git a/pcbnew/dialogs/dialog_push_pad_properties_base.fbp b/pcbnew/dialogs/dialog_push_pad_properties_base.fbp index 3db721953e..840270d159 100644 --- a/pcbnew/dialogs/dialog_push_pad_properties_base.fbp +++ b/pcbnew/dialogs/dialog_push_pad_properties_base.fbp @@ -1,365 +1,375 @@ - + - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_push_pad_properties_base - 1000 - none - - 1 - dialog_push_pad_properties - - . - - 1 - 1 - 1 - 1 - UI - 0 - 0 - - 0 - wxAUI_MGR_DEFAULT - - - - 1 - 1 - impl_virtual - - - - 0 - wxID_ANY - + + + C++ + + 1 + connect + none + + + 0 + 0 + res + UTF-8 + dialog_push_pad_properties_base + 1000 + 1 + 1 + UI + dialog_push_pad_properties + . + 0 + source_name + 1 + 0 + source_name + + + 1 + 1 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + + 1 + 0 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_PUSH_PAD_PROPERTIES_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Push Pad Properties + + 0 + + + + + + bMainSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 1 + - DIALOG_PUSH_PAD_PROPERTIES_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Push Pad Properties - - - - - + bLeftSizer + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 1 + + wxID_ANY + Options - bMainSizer + sbSizer1 wxVERTICAL + 1 none - - 5 - wxALL|wxEXPAND - 1 - - - bLeftSizer - wxVERTICAL - none - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 1 - - wxID_ANY - Options - - sbSizer1 - wxVERTICAL - 1 - none - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Do not modify pads having a different shape - - 0 - - - 0 - - 1 - m_Pad_Shape_Filter_CB - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Do not modify pads having different layers - - 0 - - - 0 - - 1 - m_Pad_Layer_Filter_CB - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Do not modify pads having a different orientation - - 0 - - - 0 - - 1 - m_Pad_Orient_Filter_CB - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Do not modify pads having a different type - - 0 - - - 0 - - 1 - m_Pad_Type_Filter_CB - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Do not modify pads having a different shape + + 0 + + + 0 + + 1 + m_Pad_Shape_Filter_CB + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizer1 - protected - PadPropertiesAccept - PadPropertiesAccept - + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Do not modify pads having different layers + + 0 + + + 0 + + 1 + m_Pad_Layer_Filter_CB + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Do not modify pads having a different orientation + + 0 + + + 0 + + 1 + m_Pad_Orient_Filter_CB + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Do not modify pads having a different type + + 0 + + + 0 + + 1 + m_Pad_Type_Filter_CB + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer1 + protected + PadPropertiesAccept + PadPropertiesAccept + + + + diff --git a/pcbnew/dialogs/dialog_push_pad_properties_base.h b/pcbnew/dialogs/dialog_push_pad_properties_base.h index bba42d9e66..657e55bc1a 100644 --- a/pcbnew/dialogs/dialog_push_pad_properties_base.h +++ b/pcbnew/dialogs/dialog_push_pad_properties_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -24,7 +24,6 @@ /////////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_PUSH_PAD_PROPERTIES_BASE /////////////////////////////////////////////////////////////////////////////// @@ -42,13 +41,14 @@ class DIALOG_PUSH_PAD_PROPERTIES_BASE : public DIALOG_SHIM wxButton* m_sdbSizer1Apply; wxButton* m_sdbSizer1Cancel; - // Virtual event handlers, overide them in your derived class + // Virtual event handlers, override them in your derived class virtual void PadPropertiesAccept( wxCommandEvent& event ) { event.Skip(); } public: DIALOG_PUSH_PAD_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Push Pad Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_PUSH_PAD_PROPERTIES_BASE(); }; diff --git a/pcbnew/dialogs/dialog_reference_image_properties.cpp b/pcbnew/dialogs/dialog_reference_image_properties.cpp index 621efd74b5..aac45a949e 100644 --- a/pcbnew/dialogs/dialog_reference_image_properties.cpp +++ b/pcbnew/dialogs/dialog_reference_image_properties.cpp @@ -41,8 +41,7 @@ DIALOG_REFERENCE_IMAGE_PROPERTIES::DIALOG_REFERENCE_IMAGE_PROPERTIES( PCB_BASE_F m_posY( aParent, m_YPosLabel, m_ModPositionY, m_YPosUnit ) { // Create the image editor page - m_imageEditor = - new PANEL_IMAGE_EDITOR( m_Notebook, aBitmap.GetReferenceImage().MutableImage() ); + m_imageEditor = new PANEL_IMAGE_EDITOR( m_Notebook, aBitmap.GetReferenceImage().MutableImage() ); m_Notebook->AddPage( m_imageEditor, _( "Image" ), false ); m_posX.SetCoordType( ORIGIN_TRANSFORMS::ABS_X_COORD ); @@ -85,9 +84,8 @@ bool DIALOG_REFERENCE_IMAGE_PROPERTIES::TransferDataToWindow() m_LayerSelectionCtrl->SetLayerSelection( m_bitmap.GetLayer() ); m_cbLocked->SetValue( m_bitmap.IsLocked() ); - m_cbLocked->SetToolTip( _( "Locked items cannot be freely moved and oriented on the canvas " - "and can only be selected when the 'Locked items' checkbox is " - "checked in the selection filter." ) ); + m_cbLocked->SetToolTip( _( "Locked items cannot be freely moved and oriented on the canvas and can only be " + "selected when the 'Locked items' checkbox is checked in the selection filter." ) ); return true; } diff --git a/pcbnew/dialogs/dialog_render_job.h b/pcbnew/dialogs/dialog_render_job.h index c63c7fb6e3..2b62738971 100644 --- a/pcbnew/dialogs/dialog_render_job.h +++ b/pcbnew/dialogs/dialog_render_job.h @@ -35,7 +35,7 @@ public: void setSelectedFormat( JOB_PCB_RENDER::FORMAT aFormat ); JOB_PCB_RENDER::SIDE getSelectedSide(); - void setSelectedSide( JOB_PCB_RENDER::SIDE aSide ); + void setSelectedSide( JOB_PCB_RENDER::SIDE aSide ); JOB_PCB_RENDER::BG_STYLE getSelectedBgStyle(); void setSelectedBgStyle( JOB_PCB_RENDER::BG_STYLE aBgStyle );